about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/22_parser_limitations.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/22_parser_limitations.txt')
-rw-r--r--js/scripting-lang/tests/22_parser_limitations.txt115
1 files changed, 115 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/22_parser_limitations.txt b/js/scripting-lang/tests/22_parser_limitations.txt
new file mode 100644
index 0000000..6d267b8
--- /dev/null
+++ b/js/scripting-lang/tests/22_parser_limitations.txt
@@ -0,0 +1,115 @@
+/* Unit Test: Parser Limitations for Enhanced Case Statements */
+/* Tests: Multi-value patterns with expressions, table access, function calls */
+
+/* ======================================== */
+/* MAIN BLOCKER: Multi-value patterns with expressions */
+/* ======================================== */
+
+/* Test 1: Basic multi-value with expressions in parentheses */
+test_multi_expr : x y -> 
+  when (x % 2) (y % 2) is
+    0 0 then "both even"
+    0 1 then "x even, y odd"
+    1 0 then "x odd, y even"
+    1 1 then "both odd";
+
+/* Test 2: FizzBuzz-style multi-value patterns */
+fizzbuzz_test : n ->
+  when (n % 3) (n % 5) is
+    0 0 then "FizzBuzz"
+    0 _ then "Fizz"
+    _ 0 then "Buzz"
+    _ _ then n;
+
+/* Test 3: Complex expressions in multi-value patterns */
+complex_multi : x y ->
+  when ((x + 1) % 2) ((y - 1) % 2) is
+    0 0 then "both transformed even"
+    0 1 then "x transformed even, y transformed odd"
+    1 0 then "x transformed odd, y transformed even"
+    1 1 then "both transformed odd";
+
+/* Test 4: Function calls in multi-value patterns */
+is_even : n -> n % 2 = 0;
+is_positive : n -> n > 0;
+
+test_func_multi : x y ->
+  when (is_even x) (is_positive y) is
+    true true then "x even and y positive"
+    true false then "x even and y not positive"
+    false true then "x odd and y positive"
+    false false then "x odd and y not positive";
+
+/* ======================================== */
+/* SECONDARY LIMITATIONS: Table access and function calls */
+/* ======================================== */
+
+/* Test 5: Table access in when expressions */
+user : {role: "admin", level: 5};
+test_table_access : u ->
+  when u.role is
+    "admin" then "admin user"
+    "user" then "regular user"
+    _ then "unknown role";
+
+/* Test 6: Function calls in when expressions */
+test_func_call : n ->
+  when (is_even n) is
+    true then "even number"
+    false then "odd number";
+
+/* Test 7: Complex function calls in when expressions */
+complex_func : n -> (n % 3 = 0) and (n % 5 = 0);
+test_complex_func : n ->
+  when (complex_func n) is
+    true then "divisible by both 3 and 5"
+    false then "not divisible by both";
+
+/* ======================================== */
+/* CONTROL TESTS: Should work with current parser */
+/* ======================================== */
+
+/* Test 8: Simple value matching (control) */
+test_simple : n ->
+  when n is
+    0 then "zero"
+    1 then "one"
+    _ then "other";
+
+/* Test 9: Single complex expressions with parentheses (control) */
+test_single_expr : n ->
+  when (n % 3) is
+    0 then "divisible by 3"
+    _ then "not divisible by 3";
+
+/* Test 10: Multiple simple values (control) */
+test_multi_simple : x y ->
+  when x y is
+    0 0 then "both zero"
+    0 _ then "x zero"
+    _ 0 then "y zero"
+    _ _ then "neither zero";
+
+/* ======================================== */
+/* TEST EXECUTION */
+/* ======================================== */
+
+/* Execute tests that should work */
+result1 : test_simple 5;
+result2 : test_single_expr 15;
+result3 : test_multi_simple 0 5;
+
+/* These should fail with current parser */
+result4 : test_multi_expr 4 6;  /* Should return "both even" */
+result5 : fizzbuzz_test 15;     /* Should return "FizzBuzz" */
+result6 : test_table_access user; /* Should return "admin user" */
+result7 : test_func_call 4;     /* Should return "even number" */
+
+/* Output results */
+..out result1;
+..out result2;
+..out result3;
+..out result4;
+..out result5;
+..out result6;
+..out result7; 
\ No newline at end of file