about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests')
-rw-r--r--js/scripting-lang/scratch_tests/fizzbuzz_explorations.txt7
-rw-r--r--js/scripting-lang/scratch_tests/test_and_negative.txt6
-rw-r--r--js/scripting-lang/scratch_tests/test_and_negative_fixed.txt14
-rw-r--r--js/scripting-lang/scratch_tests/test_and_operator.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_and_operator_simple.txt26
-rw-r--r--js/scripting-lang/scratch_tests/test_and_parentheses.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_and_simple.txt8
-rw-r--r--js/scripting-lang/scratch_tests/test_ast_debug.txt11
-rw-r--r--js/scripting-lang/scratch_tests/test_available_functions.txt26
-rw-r--r--js/scripting-lang/scratch_tests/test_bool_debug.txt15
-rw-r--r--js/scripting-lang/scratch_tests/test_comparison_debug.txt10
-rw-r--r--js/scripting-lang/scratch_tests/test_complex_expr_debug.txt16
-rw-r--r--js/scripting-lang/scratch_tests/test_complex_func_debug.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_complex_validation_debug.txt21
-rw-r--r--js/scripting-lang/scratch_tests/test_complex_validation_only.txt14
-rw-r--r--js/scripting-lang/scratch_tests/test_control_only.txt25
-rw-r--r--js/scripting-lang/scratch_tests/test_coord_debug.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_coord_only.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_debug_enhanced_case.txt19
-rw-r--r--js/scripting-lang/scratch_tests/test_debug_equals.txt26
-rw-r--r--js/scripting-lang/scratch_tests/test_debug_func_call.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_debug_func_call_when.txt17
-rw-r--r--js/scripting-lang/scratch_tests/test_debug_map.txt27
-rw-r--r--js/scripting-lang/scratch_tests/test_direct_verification.txt63
-rw-r--r--js/scripting-lang/scratch_tests/test_each_debug.txt28
-rw-r--r--js/scripting-lang/scratch_tests/test_enhanced_case_final.txt62
-rw-r--r--js/scripting-lang/scratch_tests/test_enhanced_case_verification.txt229
-rw-r--r--js/scripting-lang/scratch_tests/test_enhanced_debug.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_equals_function.txt17
-rw-r--r--js/scripting-lang/scratch_tests/test_exact_expr_debug.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_first_part.txt48
-rw-r--r--js/scripting-lang/scratch_tests/test_fizzbuzz.txt16
-rw-r--r--js/scripting-lang/scratch_tests/test_fizzbuzz_only.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_func_call_debug.txt22
-rw-r--r--js/scripting-lang/scratch_tests/test_func_call_debug2.txt11
-rw-r--r--js/scripting-lang/scratch_tests/test_func_call_only.txt10
-rw-r--r--js/scripting-lang/scratch_tests/test_func_call_original.txt10
-rw-r--r--js/scripting-lang/scratch_tests/test_func_call_value.txt12
-rw-r--r--js/scripting-lang/scratch_tests/test_func_call_when.txt10
-rw-r--r--js/scripting-lang/scratch_tests/test_func_calls_debug.txt17
-rw-r--r--js/scripting-lang/scratch_tests/test_func_calls_only.txt17
-rw-r--r--js/scripting-lang/scratch_tests/test_func_debug_detailed.txt24
-rw-r--r--js/scripting-lang/scratch_tests/test_func_eval.txt9
-rw-r--r--js/scripting-lang/scratch_tests/test_func_no_match.txt11
-rw-r--r--js/scripting-lang/scratch_tests/test_func_pattern.txt11
-rw-r--r--js/scripting-lang/scratch_tests/test_func_return.txt9
-rw-r--r--js/scripting-lang/scratch_tests/test_function_body.txt15
-rw-r--r--js/scripting-lang/scratch_tests/test_function_calls_in_tables.txt28
-rw-r--r--js/scripting-lang/scratch_tests/test_listen_emit_basic.txt16
-rw-r--r--js/scripting-lang/scratch_tests/test_listen_emit_comprehensive.txt48
-rw-r--r--js/scripting-lang/scratch_tests/test_listen_emit_final.txt44
-rw-r--r--js/scripting-lang/scratch_tests/test_listen_emit_simple.txt16
-rw-r--r--js/scripting-lang/scratch_tests/test_logical_and_debug.txt26
-rw-r--r--js/scripting-lang/scratch_tests/test_minimal_enhanced.txt32
-rw-r--r--js/scripting-lang/scratch_tests/test_minimal_enhanced_case.txt11
-rw-r--r--js/scripting-lang/scratch_tests/test_minimal_when.txt9
-rw-r--r--js/scripting-lang/scratch_tests/test_modulo_in_when.txt30
-rw-r--r--js/scripting-lang/scratch_tests/test_multi_validation_debug.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_multi_validation_only.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_multi_validation_simple.txt13
-rw-r--r--js/scripting-lang/scratch_tests/test_multi_value_expr.txt10
-rw-r--r--js/scripting-lang/scratch_tests/test_multiple_values_parens.txt29
-rw-r--r--js/scripting-lang/scratch_tests/test_nested_only.txt15
-rw-r--r--js/scripting-lang/scratch_tests/test_parens_disambiguation.txt29
-rw-r--r--js/scripting-lang/scratch_tests/test_parens_in_when.txt22
-rw-r--r--js/scripting-lang/scratch_tests/test_parens_multiple.txt37
-rw-r--r--js/scripting-lang/scratch_tests/test_pattern_debug.txt14
-rw-r--r--js/scripting-lang/scratch_tests/test_predicate_functions.txt35
-rw-r--r--js/scripting-lang/scratch_tests/test_run_function.js24
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_and.txt14
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_fizzbuzz.txt43
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_func_call.txt10
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_harness.txt7
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_multiple.txt8
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_verification.txt51
-rw-r--r--js/scripting-lang/scratch_tests/test_simple_when_equals.txt17
-rw-r--r--js/scripting-lang/scratch_tests/test_table_access_debug.txt15
-rw-r--r--js/scripting-lang/scratch_tests/test_table_access_in_functions.txt22
-rw-r--r--js/scripting-lang/scratch_tests/test_table_access_only.txt15
-rw-r--r--js/scripting-lang/scratch_tests/test_table_access_when.txt11
-rw-r--r--js/scripting-lang/scratch_tests/test_when_pattern_matching.txt25
-rw-r--r--js/scripting-lang/scratch_tests/test_working_multiple.txt18
82 files changed, 1798 insertions, 28 deletions
diff --git a/js/scripting-lang/scratch_tests/fizzbuzz_explorations.txt b/js/scripting-lang/scratch_tests/fizzbuzz_explorations.txt
new file mode 100644
index 0000000..fc6c7d1
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/fizzbuzz_explorations.txt
@@ -0,0 +1,7 @@
+predicates : n -> apply @logicalAnd (equals (n % 3) 0) (equals (n % 5) 0);
+fizzbuzz : n ->
+  when predicates n is
+    true then "FizzBuzz"
+    _ then n;
+
+..out fizzbuzz 100;
diff --git a/js/scripting-lang/scratch_tests/test_and_negative.txt b/js/scripting-lang/scratch_tests/test_and_negative.txt
new file mode 100644
index 0000000..7aafd24
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_and_negative.txt
@@ -0,0 +1,6 @@
+/* Test and operator with negative numbers */
+
+/* Test the problematic expression */
+result1 : (-5 >= 0) and (-5 <= 120);
+
+..out result1; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_and_negative_fixed.txt b/js/scripting-lang/scratch_tests/test_and_negative_fixed.txt
new file mode 100644
index 0000000..f10bd9b
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_and_negative_fixed.txt
@@ -0,0 +1,14 @@
+/* Test and operator with negative numbers - fixed syntax */
+
+/* Test with proper parentheses */
+result1 : ((-5) >= 0) and ((-5) <= 120);
+
+/* Test step by step */
+step1 : (-5) >= 0;
+step2 : (-5) <= 120;
+result2 : step1 and step2;
+
+..out result1;
+..out step1;
+..out step2;
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_and_operator.txt b/js/scripting-lang/scratch_tests/test_and_operator.txt
new file mode 100644
index 0000000..b4624ff
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_and_operator.txt
@@ -0,0 +1,13 @@
+/* Test the and operator in complex expressions */
+
+/* Test the complex expression directly */
+test_expr : age -> age >= 0 and age <= 120;
+
+/* Test with different values */
+result1 : test_expr 30;  /* Should be true */
+result2 : test_expr 150; /* Should be false */
+result3 : test_expr -5;  /* Should be false */
+
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_and_operator_simple.txt b/js/scripting-lang/scratch_tests/test_and_operator_simple.txt
new file mode 100644
index 0000000..7d12e77
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_and_operator_simple.txt
@@ -0,0 +1,26 @@
+/* Test and operator as infix operator */
+
+/* Simple boolean values */
+true_val : true;
+false_val : false;
+
+/* Test and operator with simple values */
+result1 : true_val and false_val;
+result2 : false_val and true_val;
+result3 : true_val and true_val;
+
+/* Test with comparisons */
+comp1 : (-5) >= 0;  /* false */
+comp2 : (-5) <= 120; /* true */
+result4 : comp1 and comp2;  /* false and true = false */
+
+/* Test the original problematic expression */
+original : (-5 >= 0) and (-5 <= 120);
+
+..out result1;
+..out result2;
+..out result3;
+..out comp1;
+..out comp2;
+..out result4;
+..out original; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_and_parentheses.txt b/js/scripting-lang/scratch_tests/test_and_parentheses.txt
new file mode 100644
index 0000000..f799e63
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_and_parentheses.txt
@@ -0,0 +1,13 @@
+/* Test if parentheses can solve the and operator issue */
+
+/* Test the complex expression with parentheses */
+test_expr_parens : age -> (age >= 0) and (age <= 120);
+
+/* Test with different values */
+result1 : test_expr_parens 30;   /* Should be true */
+result2 : test_expr_parens 150;  /* Should be false */
+result3 : test_expr_parens -5;   /* Should be false */
+
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_and_simple.txt b/js/scripting-lang/scratch_tests/test_and_simple.txt
new file mode 100644
index 0000000..c68d4c5
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_and_simple.txt
@@ -0,0 +1,8 @@
+/* Test very simple and expression */
+
+/* Test basic and */
+result1 : 1 and 1;
+result2 : 1 and 0;
+
+..out result1;
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_ast_debug.txt b/js/scripting-lang/scratch_tests/test_ast_debug.txt
new file mode 100644
index 0000000..e8a764c
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_ast_debug.txt
@@ -0,0 +1,11 @@
+/* Debug test for AST structure */
+is_even : n -> n % 2 = 0;
+
+test_debug : n ->
+  when n is
+    is_even n then "should not match"
+    4 then "four"
+    _ then "other";
+
+result : test_debug 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_available_functions.txt b/js/scripting-lang/scratch_tests/test_available_functions.txt
new file mode 100644
index 0000000..0274711
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_available_functions.txt
@@ -0,0 +1,26 @@
+/* Test to see what functions are available */
+
+/* Test basic arithmetic */
+result1 : 5 + 3;
+..out "5 + 3:";
+..out result1;
+
+/* Test basic comparison */
+result2 : 5 = 3;
+..out "5 = 3:";
+..out result2;
+
+result3 : 5 = 5;
+..out "5 = 5:";
+..out result3;
+
+/* Test function definition */
+double : x -> x * 2;
+result4 : double 5;
+..out "double 5:";
+..out result4;
+
+/* Test table creation */
+table : {1, 2, 3};
+..out "table:";
+..out table; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_bool_debug.txt b/js/scripting-lang/scratch_tests/test_bool_debug.txt
new file mode 100644
index 0000000..8f05705
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_bool_debug.txt
@@ -0,0 +1,15 @@
+/* Test boolean pattern matching more thoroughly */
+
+/* Test with direct boolean values */
+test1 : when true is
+  true then "true matched"
+  false then "false matched"
+  _ then "wildcard matched";
+
+test2 : when false is
+  true then "true matched"
+  false then "false matched"
+  _ then "wildcard matched";
+
+..out test1;
+..out test2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_comparison_debug.txt b/js/scripting-lang/scratch_tests/test_comparison_debug.txt
new file mode 100644
index 0000000..c2d442e
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_comparison_debug.txt
@@ -0,0 +1,10 @@
+/* Debug test for comparison logic */
+is_even : n -> n % 2 = 0;
+
+test_debug : n ->
+  when (is_even n) is
+    true then "even"
+    false then "odd";
+
+result : test_debug 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_complex_expr_debug.txt b/js/scripting-lang/scratch_tests/test_complex_expr_debug.txt
new file mode 100644
index 0000000..0ca7265
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_complex_expr_debug.txt
@@ -0,0 +1,16 @@
+/* Test complex expression in multi-value pattern */
+
+/* Test the complex expression directly */
+test_expr : age -> age >= 0 and age <= 120;
+
+/* Test with complex expression */
+validate_user : name age ->
+  when (name != "") (test_expr age) is
+    true true then "valid user"
+    true false then "invalid age"
+    false true then "invalid name"
+    false false then "invalid user";
+
+/* Test user validation */
+valid_user : validate_user "Alice" 30;
+..out valid_user; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_complex_func_debug.txt b/js/scripting-lang/scratch_tests/test_complex_func_debug.txt
new file mode 100644
index 0000000..dacb3ca
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_complex_func_debug.txt
@@ -0,0 +1,13 @@
+/* Test complex validation function directly */
+
+/* Complex function for testing */
+complex_validation : x y -> (x > 0) and (y > 0) and (x + y > 10);
+
+/* Test the function directly */
+test1 : complex_validation 5 8;    /* Should be true */
+test2 : complex_validation 0 8;    /* Should be false */
+test3 : complex_validation 5 3;    /* Should be false */
+
+..out test1;
+..out test2;
+..out test3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_complex_validation_debug.txt b/js/scripting-lang/scratch_tests/test_complex_validation_debug.txt
new file mode 100644
index 0000000..7c22dad
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_complex_validation_debug.txt
@@ -0,0 +1,21 @@
+/* Test complex validation part */
+
+/* Complex function for testing */
+complex_validation : x y -> (x > 0) and (y > 0) and (x + y > 10);
+
+/* Using complex function in pattern */
+validate_pair : x y ->
+  when (complex_validation x y) is
+    true then "valid pair"
+    false then "invalid pair";
+
+/* Test complex validation */
+valid_pair : validate_pair 5 8;    /* 5>0, 8>0, 5+8>10 -> true */
+invalid_pair1 : validate_pair 0 8; /* 0>0 is false */
+invalid_pair2 : validate_pair 5 3; /* 5+3>10 is false */
+
+/* Output complex validation results */
+..out "Complex Validation Results:";
+..out valid_pair;
+..out invalid_pair1;
+..out invalid_pair2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_complex_validation_only.txt b/js/scripting-lang/scratch_tests/test_complex_validation_only.txt
new file mode 100644
index 0000000..d4e0a4a
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_complex_validation_only.txt
@@ -0,0 +1,14 @@
+/* Test just the complex validation part */
+
+/* Complex function for testing */
+complex_validation : x y -> (x > 0) and (y > 0) and (x + y > 10);
+
+/* Using complex function in pattern */
+validate_pair : x y ->
+  when (complex_validation x y) is
+    true then "valid pair"
+    false then "invalid pair";
+
+/* Test complex validation */
+valid_pair : validate_pair 5 8;
+..out valid_pair; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_control_only.txt b/js/scripting-lang/scratch_tests/test_control_only.txt
new file mode 100644
index 0000000..5e4cc77
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_control_only.txt
@@ -0,0 +1,25 @@
+/* Control tests that should work */
+test_simple : n ->
+  when n is
+    0 then "zero"
+    1 then "one"
+    _ then "other";
+
+test_single_expr : n ->
+  when (n % 3) is
+    0 then "divisible by 3"
+    _ then "not divisible by 3";
+
+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";
+
+result1 : test_simple 5;
+result2 : test_single_expr 15;
+result3 : test_multi_simple 0 5;
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_coord_debug.txt b/js/scripting-lang/scratch_tests/test_coord_debug.txt
new file mode 100644
index 0000000..8ef62d1
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_coord_debug.txt
@@ -0,0 +1,13 @@
+/* Test complex coordinate classification */
+
+/* Complex coordinate classification */
+classify_coordinates : 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 coordinate classification */
+coord1 : classify_coordinates 1 1;
+..out coord1; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_coord_only.txt b/js/scripting-lang/scratch_tests/test_coord_only.txt
new file mode 100644
index 0000000..390e843
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_coord_only.txt
@@ -0,0 +1,13 @@
+/* Test just the complex coordinate classification */
+
+/* Complex coordinate classification */
+classify_coordinates : 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 coordinate classification */
+coord1 : classify_coordinates 1 1;
+..out coord1; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_debug_enhanced_case.txt b/js/scripting-lang/scratch_tests/test_debug_enhanced_case.txt
new file mode 100644
index 0000000..2090669
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_debug_enhanced_case.txt
@@ -0,0 +1,19 @@
+/* Debug test for enhanced case statements */
+
+/* Simple test first */
+mod3 : n -> n % 3;
+mod5 : n -> n % 5;
+is_zero : x -> x = 0;
+
+/* Test basic function calls */
+test1 : mod3 15;
+test2 : mod5 15;
+test3 : is_zero 0;
+
+..out test1;
+..out test2;
+..out test3;
+
+/* Test table with function calls */
+test_table : {mod3 15, mod5 15};
+..out test_table; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_debug_equals.txt b/js/scripting-lang/scratch_tests/test_debug_equals.txt
new file mode 100644
index 0000000..da3e0cd
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_debug_equals.txt
@@ -0,0 +1,26 @@
+/* Debug test for equals function */
+
+/* Test equals directly */
+result1 : equals 5 3;
+..out "equals 5 3:";
+..out result1;
+
+result2 : equals 0 0;
+..out "equals 0 0:";
+..out result2;
+
+/* Test is_zero function */
+is_zero : x -> equals x 0;
+result3 : is_zero 0;
+..out "is_zero 0:";
+..out result3;
+
+result4 : is_zero 5;
+..out "is_zero 5:";
+..out result4;
+
+/* Test map with is_zero */
+test_values : {0, 1, 2};
+zero_test : map @is_zero test_values;
+..out "map @is_zero {0, 1, 2}:";
+..out zero_test; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_debug_func_call.txt b/js/scripting-lang/scratch_tests/test_debug_func_call.txt
new file mode 100644
index 0000000..5b3ae21
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_debug_func_call.txt
@@ -0,0 +1,13 @@
+/* Debug test for function calls */
+is_even : n -> n % 2 = 0;
+
+test_debug : n ->
+  when n is
+    0 then "zero"
+    1 then "one"
+    _ then "other";
+
+result1 : test_debug 0;
+result2 : is_even 4;
+..out result1;
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_debug_func_call_when.txt b/js/scripting-lang/scratch_tests/test_debug_func_call_when.txt
new file mode 100644
index 0000000..8132d0b
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_debug_func_call_when.txt
@@ -0,0 +1,17 @@
+/* Debug test for function calls in when expressions */
+is_even : n -> n % 2 = 0;
+
+test_debug : n ->
+  when is_even n is
+    true then "even"
+    false then "odd";
+
+/* Test the function call separately */
+result1 : is_even 4;
+result2 : is_even 5;
+
+/* Test the when expression */
+result3 : test_debug 4;
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_debug_map.txt b/js/scripting-lang/scratch_tests/test_debug_map.txt
new file mode 100644
index 0000000..7d178f2
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_debug_map.txt
@@ -0,0 +1,27 @@
+/* Debug test for map function */
+
+/* Test basic map functionality */
+double : x -> x * 2;
+numbers : {1, 2, 3};
+doubled : map @double numbers;
+..out "Doubled numbers:";
+..out doubled;
+
+/* Test map with equals */
+is_zero : x -> equals x 0;
+test_values : {0, 1, 2};
+zero_test : map @is_zero test_values;
+..out "Zero test:";
+..out zero_test;
+
+/* Test with our specific case */
+mod3 : n -> n % 3;
+mod5 : n -> n % 5;
+div_15 : {mod3 15, mod5 15};
+..out "Div 15:";
+..out div_15;
+
+divisibility : n -> map @is_zero {mod3 n, mod5 n};
+result : divisibility 15;
+..out "Divisibility result:";
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_direct_verification.txt b/js/scripting-lang/scratch_tests/test_direct_verification.txt
new file mode 100644
index 0000000..6302c05
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_direct_verification.txt
@@ -0,0 +1,63 @@
+/* Direct verification test for enhanced case statements */
+
+/* Test 1: Basic table creation */
+basic : {1, 2, 3};
+..out "Basic table:";
+..out basic;
+
+/* Test 2: Auto-indexed table with expressions */
+/* Work around parser limitation by using variables */
+a : 5 % 3;
+b : 5 % 5;
+expr : {a, b};
+..out "Expression table:";
+..out expr;
+
+/* Test 3: Map with equals 0 */
+/* Work around parser limitation by using variables */
+c : 15 % 3;
+d : 15 % 5;
+is_zero : x -> equals x 0;
+mapped : map @is_zero {c, d};
+..out "Mapped table:";
+..out mapped;
+
+/* Test 4: Simple table pattern matching */
+test_table : {1: true, 2: false};
+result : when test_table is
+    {1: true, 2: true} then "both true"
+    {1: true, 2: false} then "first true"
+    {1: false, 2: true} then "second true"
+    {1: false, 2: false} then "both false";
+..out "Pattern match result:";
+..out result;
+
+/* Test 5: FizzBuzz divisibility function */
+/* Work around parser limitation by using a helper function */
+mod3 : n -> n % 3;
+mod5 : n -> n % 5;
+is_zero : x -> equals x 0;
+divisibility : n -> map @is_zero {mod3 n, mod5 n};
+
+div_15 : divisibility 15;
+..out "Divisibility for 15:";
+..out div_15;
+
+/* Test 6: Complete FizzBuzz */
+fizzbuzz : n ->
+  when divisibility n is
+    {1: true, 2: true} then "FizzBuzz"
+    {1: true, 2: false} then "Fizz"
+    {1: false, 2: true} then "Buzz"
+    {1: false, 2: false} then n;
+
+fizz_15 : fizzbuzz 15;
+fizz_3 : fizzbuzz 3;
+fizz_5 : fizzbuzz 5;
+fizz_7 : fizzbuzz 7;
+
+..out "FizzBuzz results:";
+..out "15: " + fizz_15;
+..out "3: " + fizz_3;
+..out "5: " + fizz_5;
+..out "7: " + fizz_7; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_each_debug.txt b/js/scripting-lang/scratch_tests/test_each_debug.txt
deleted file mode 100644
index 98bcac4..0000000
--- a/js/scripting-lang/scratch_tests/test_each_debug.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Debug test for each combinator */
-
-/* Test basic each usage */
-numbers : {1, 2, 3, 4, 5};
-add_ten : x -> x + 10;
-
-/* Test 1: each with single table */
-result1 : each @add_ten numbers;
-..out "Test 1 - each with single table:";
-..out result1;
-
-/* Test 2: each with table and scalar */
-result2 : each @add numbers 10;
-..out "Test 2 - each with table and scalar:";
-..out result2;
-
-/* Test 3: each with two tables */
-table1 : {a: 1, b: 2, c: 3};
-table2 : {a: 10, b: 20, c: 30};
-result3 : each @add table1 table2;
-..out "Test 3 - each with two tables:";
-..out result3;
-
-/* Test 4: each with partial application */
-add_to_ten : each @add 10;
-result4 : add_to_ten numbers;
-..out "Test 4 - each with partial application:";
-..out result4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_enhanced_case_final.txt b/js/scripting-lang/scratch_tests/test_enhanced_case_final.txt
new file mode 100644
index 0000000..4551122
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_enhanced_case_final.txt
@@ -0,0 +1,62 @@
+/* Final verification test for enhanced case statements */
+
+/* Test 1: Basic table creation */
+basic : {1, 2, 3};
+..out "Basic table:";
+..out basic;
+
+/* Test 2: Auto-indexed table with expressions */
+/* Work around parser limitation by using variables */
+a : 5 % 3;
+b : 5 % 5;
+expr : {a, b};
+..out "Expression table:";
+..out expr;
+
+/* Test 3: Map with equals 0 */
+/* Work around parser limitation by using variables */
+c : 15 % 3;
+d : 15 % 5;
+is_zero : x -> x = 0;
+mapped : map @is_zero {c, d};
+..out "Mapped table:";
+..out mapped;
+
+/* Test 4: Simple table pattern matching */
+test_table : {1: true, 2: false};
+result : when test_table is
+    {1: true, 2: true} then "both true"
+    {1: true, 2: false} then "first true"
+    {1: false, 2: true} then "second true"
+    {1: false, 2: false} then "both false";
+..out "Pattern match result:";
+..out result;
+
+/* Test 5: FizzBuzz divisibility function */
+/* Work around parser limitation by using a helper function */
+mod3 : n -> n % 3;
+mod5 : n -> n % 5;
+divisibility : n -> map @is_zero {mod3 n, mod5 n};
+
+div_15 : divisibility 15;
+..out "Divisibility for 15:";
+..out div_15;
+
+/* Test 6: Complete FizzBuzz */
+fizzbuzz : n ->
+  when divisibility n is
+    {1: true, 2: true} then "FizzBuzz"
+    {1: true, 2: false} then "Fizz"
+    {1: false, 2: true} then "Buzz"
+    {1: false, 2: false} then n;
+
+fizz_15 : fizzbuzz 15;
+fizz_3 : fizzbuzz 3;
+fizz_5 : fizzbuzz 5;
+fizz_7 : fizzbuzz 7;
+
+..out "FizzBuzz results:";
+..out "15: " + fizz_15;
+..out "3: " + fizz_3;
+..out "5: " + fizz_5;
+..out "7: " + fizz_7; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_enhanced_case_verification.txt b/js/scripting-lang/scratch_tests/test_enhanced_case_verification.txt
new file mode 100644
index 0000000..011a433
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_enhanced_case_verification.txt
@@ -0,0 +1,229 @@
+/* Enhanced Case Statement Verification Tests */
+/* Testing core assumptions for FizzBuzz and tuple-like pattern matching */
+
+/* ===== TEST 1: AUTO-INDEXED TABLE CREATION ===== */
+..out "=== TEST 1: AUTO-INDEXED TABLE CREATION ===";
+
+/* Test basic auto-indexed table */
+basic_table : {1, 2, 3};
+..out "Basic table:";
+..out basic_table;
+
+/* Test auto-indexed table with expressions */
+expr_table : {5 % 3, 5 % 5, 5 % 2};
+..out "Expression table (5 % 3, 5 % 5, 5 % 2):";
+..out expr_table;
+
+/* Test with FizzBuzz-style expressions */
+n : 15;
+fizzbuzz_expr : {n % 3, n % 5};
+..out "FizzBuzz expressions for n=15:";
+..out fizzbuzz_expr;
+
+/* ===== TEST 2: MAP WITH TABLE TRANSFORMATION ===== */
+..out "=== TEST 2: MAP WITH TABLE TRANSFORMATION ===";
+
+/* Test map with equals 0 */
+test_map : map @(equals 0) {15 % 3, 15 % 5};
+..out "Map equals 0 on {15 % 3, 15 % 5}:";
+..out test_map;
+
+/* Test with different numbers */
+test_map_3 : map @(equals 0) {3 % 3, 3 % 5};
+..out "Map equals 0 on {3 % 3, 3 % 5}:";
+..out test_map_3;
+
+test_map_5 : map @(equals 0) {5 % 3, 5 % 5};
+..out "Map equals 0 on {5 % 3, 5 % 5}:";
+..out test_map_5;
+
+test_map_7 : map @(equals 0) {7 % 3, 7 % 5};
+..out "Map equals 0 on {7 % 3, 7 % 5}:";
+..out test_map_7;
+
+/* ===== TEST 3: TABLE PATTERN MATCHING ===== */
+..out "=== TEST 3: TABLE PATTERN MATCHING ===";
+
+/* Test simple table pattern matching */
+simple_table : {1: true, 2: false};
+simple_result : when simple_table is
+    {1: true, 2: true} then "both true"
+    {1: true, 2: false} then "first true"
+    {1: false, 2: true} then "second true"
+    {1: false, 2: false} then "both false";
+..out "Simple table pattern matching:";
+..out simple_result;
+
+/* Test with actual FizzBuzz-style data */
+fizzbuzz_data : {1: true, 2: true};
+fizzbuzz_result : when fizzbuzz_data is
+    {1: true, 2: true} then "FizzBuzz"
+    {1: true, 2: false} then "Fizz"
+    {1: false, 2: true} then "Buzz"
+    {1: false, 2: false} then "neither";
+..out "FizzBuzz-style pattern matching:";
+..out fizzbuzz_result;
+
+/* Test with different combinations */
+fizz_data : {1: true, 2: false};
+fizz_result : when fizz_data is
+    {1: true, 2: true} then "FizzBuzz"
+    {1: true, 2: false} then "Fizz"
+    {1: false, 2: true} then "Buzz"
+    {1: false, 2: false} then "neither";
+..out "Fizz pattern matching:";
+..out fizz_result;
+
+/* ===== TEST 4: INTEGRATED FIZZBUZZ TEST ===== */
+..out "=== TEST 4: INTEGRATED FIZZBUZZ TEST ===";
+
+/* Create the divisibility function */
+divisibility : n -> map @(equals 0) {n % 3, n % 5};
+
+/* Test the function with different inputs */
+div_15 : divisibility 15;
+div_3 : divisibility 3;
+div_5 : divisibility 5;
+div_7 : divisibility 7;
+
+..out "Divisibility results:";
+..out "15: " + div_15;
+..out "3: " + div_3;
+..out "5: " + div_5;
+..out "7: " + div_7;
+
+/* Test the complete FizzBuzz function */
+fizzbuzz : n ->
+  when divisibility n is
+    {1: true, 2: true} then "FizzBuzz"
+    {1: true, 2: false} then "Fizz"
+    {1: false, 2: true} then "Buzz"
+    {1: false, 2: false} then n;
+
+/* Test FizzBuzz with various inputs */
+..out "FizzBuzz results:";
+..out "fizzbuzz 15: " + fizzbuzz 15;
+..out "fizzbuzz 3: " + fizzbuzz 3;
+..out "fizzbuzz 5: " + fizzbuzz 5;
+..out "fizzbuzz 7: " + fizzbuzz 7;
+..out "fizzbuzz 0: " + fizzbuzz 0;
+..out "fizzbuzz 1: " + fizzbuzz 1;
+
+/* ===== TEST 5: ALTERNATIVE APPROACHES ===== */
+..out "=== TEST 5: ALTERNATIVE APPROACHES ===";
+
+/* Option A: Multiple value patterns */
+fizzbuzz_option_a : n ->
+  when (equals (n % 3) 0) (equals (n % 5) 0) is
+    true true then "FizzBuzz"
+    true false then "Fizz"
+    false true then "Buzz"
+    false false then n;
+
+..out "Option A (multiple value patterns):";
+..out "fizzbuzz_option_a 15: " + fizzbuzz_option_a 15;
+..out "fizzbuzz_option_a 3: " + fizzbuzz_option_a 3;
+..out "fizzbuzz_option_a 5: " + fizzbuzz_option_a 5;
+..out "fizzbuzz_option_a 7: " + fizzbuzz_option_a 7;
+
+/* Option B: Predicate functions with nested when */
+is_fizzbuzz : n -> apply @logicalAnd (equals (n % 3) 0) (equals (n % 5) 0);
+is_fizz : n -> equals (n % 3) 0;
+is_buzz : n -> equals (n % 5) 0;
+
+fizzbuzz_option_b : n ->
+  when is_fizzbuzz n is
+    true then "FizzBuzz"
+    _ then when is_fizz n is
+      true then "Fizz"
+      _ then when is_buzz n is
+        true then "Buzz"
+        _ then n;
+
+..out "Option B (predicate functions):";
+..out "fizzbuzz_option_b 15: " + fizzbuzz_option_b 15;
+..out "fizzbuzz_option_b 3: " + fizzbuzz_option_b 3;
+..out "fizzbuzz_option_b 5: " + fizzbuzz_option_b 5;
+..out "fizzbuzz_option_b 7: " + fizzbuzz_option_b 7;
+
+/* ===== TEST 6: EDGE CASES AND ERROR CONDITIONS ===== */
+..out "=== TEST 6: EDGE CASES AND ERROR CONDITIONS ===";
+
+/* Test with negative numbers */
+..out "Negative numbers:";
+..out "fizzbuzz -3: " + fizzbuzz -3;
+..out "fizzbuzz -5: " + fizzbuzz -5;
+..out "fizzbuzz -15: " + fizzbuzz -15;
+
+/* Test with large numbers */
+..out "Large numbers:";
+..out "fizzbuzz 30: " + fizzbuzz 30;
+..out "fizzbuzz 45: " + fizzbuzz 45;
+..out "fizzbuzz 60: " + fizzbuzz 60;
+
+/* ===== TEST 7: PERFORMANCE AND COMPLEXITY ===== */
+..out "=== TEST 7: PERFORMANCE AND COMPLEXITY ===";
+
+/* Test with a range of numbers */
+test_range : 1;
+test_result : fizzbuzz test_range;
+..out "Range test (1-20):";
+..out "1: " + test_result;
+
+test_range : 2;
+test_result : fizzbuzz test_range;
+..out "2: " + test_result;
+
+test_range : 3;
+test_result : fizzbuzz test_range;
+..out "3: " + test_result;
+
+test_range : 4;
+test_result : fizzbuzz test_range;
+..out "4: " + test_result;
+
+test_range : 5;
+test_result : fizzbuzz test_range;
+..out "5: " + test_result;
+
+test_range : 6;
+test_result : fizzbuzz test_range;
+..out "6: " + test_result;
+
+test_range : 7;
+test_result : fizzbuzz test_range;
+..out "7: " + test_result;
+
+test_range : 8;
+test_result : fizzbuzz test_range;
+..out "8: " + test_result;
+
+test_range : 9;
+test_result : fizzbuzz test_range;
+..out "9: " + test_result;
+
+test_range : 10;
+test_result : fizzbuzz test_range;
+..out "10: " + test_result;
+
+test_range : 11;
+test_result : fizzbuzz test_range;
+..out "11: " + test_result;
+
+test_range : 12;
+test_result : fizzbuzz test_range;
+..out "12: " + test_result;
+
+test_range : 13;
+test_result : fizzbuzz test_range;
+..out "13: " + test_result;
+
+test_range : 14;
+test_result : fizzbuzz test_range;
+..out "14: " + test_result;
+
+test_range : 15;
+test_result : fizzbuzz test_range;
+..out "15: " + test_result;
+
+..out "=== VERIFICATION COMPLETE ==="; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_enhanced_debug.txt b/js/scripting-lang/scratch_tests/test_enhanced_debug.txt
new file mode 100644
index 0000000..5462858
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_enhanced_debug.txt
@@ -0,0 +1,13 @@
+/* Simple test to debug enhanced case statements */
+
+/* Test 1: Basic FizzBuzz */
+fizzbuzz : n ->
+  when (n % 3) (n % 5) is
+    0 0 then "FizzBuzz"
+    0 _ then "Fizz"
+    _ 0 then "Buzz"
+    _ _ then n;
+
+/* Test basic FizzBuzz */
+result1 : fizzbuzz 15;
+..out result1; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_equals_function.txt b/js/scripting-lang/scratch_tests/test_equals_function.txt
new file mode 100644
index 0000000..91e90fd
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_equals_function.txt
@@ -0,0 +1,17 @@
+/* Test equals function */
+
+/* Test basic equals */
+test1 : equals 5 5;
+test2 : equals 5 3;
+test3 : equals 0 0;
+
+..out test1;
+..out test2;
+..out test3;
+
+/* Test equals with modulo */
+test4 : equals (15 % 3) 0;
+test5 : equals (15 % 5) 0;
+
+..out test4;
+..out test5; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_exact_expr_debug.txt b/js/scripting-lang/scratch_tests/test_exact_expr_debug.txt
new file mode 100644
index 0000000..8a6b3c5
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_exact_expr_debug.txt
@@ -0,0 +1,13 @@
+/* Test exact expression from test file */
+
+/* Multi-field validation using function calls */
+validate_user : name age ->
+  when (name != "") (age >= 0 and age <= 120) is
+    true true then "valid user"
+    true false then "invalid age"
+    false true then "invalid name"
+    false false then "invalid user";
+
+/* Test user validation */
+valid_user : validate_user "Alice" 30;
+..out valid_user; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_first_part.txt b/js/scripting-lang/scratch_tests/test_first_part.txt
new file mode 100644
index 0000000..61b2da1
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_first_part.txt
@@ -0,0 +1,48 @@
+/* Test first part of enhanced case statements */
+
+/* ===== FIZZBUZZ IMPLEMENTATION ===== */
+
+/* Classic FizzBuzz using multi-value patterns with expressions */
+fizzbuzz : n ->
+  when (n % 3) (n % 5) is
+    0 0 then "FizzBuzz"
+    0 _ then "Fizz"
+    _ 0 then "Buzz"
+    _ _ then n;
+
+/* Test FizzBuzz implementation */
+fizzbuzz_15 : fizzbuzz 15;  /* Should be "FizzBuzz" */
+fizzbuzz_3 : fizzbuzz 3;    /* Should be "Fizz" */
+fizzbuzz_5 : fizzbuzz 5;    /* Should be "Buzz" */
+fizzbuzz_7 : fizzbuzz 7;    /* Should be 7 */
+
+/* ===== TABLE ACCESS IN WHEN EXPRESSIONS ===== */
+
+/* User data for testing */
+admin_user : {role: "admin", level: 5, name: "Alice"};
+user_user : {role: "user", level: 2, name: "Bob"};
+guest_user : {role: "guest", level: 0, name: "Charlie"};
+
+/* Access control using table access in patterns */
+access_level : user ->
+  when user.role is
+    "admin" then "full access"
+    "user" then "limited access"
+    _ then "no access";
+
+/* Test access control */
+admin_access : access_level admin_user;
+user_access : access_level user_user;
+guest_access : access_level guest_user;
+
+/* Output results */
+..out "FizzBuzz Results:";
+..out fizzbuzz_15;
+..out fizzbuzz_3;
+..out fizzbuzz_5;
+..out fizzbuzz_7;
+
+..out "Access Control Results:";
+..out admin_access;
+..out user_access;
+..out guest_access; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_fizzbuzz.txt b/js/scripting-lang/scratch_tests/test_fizzbuzz.txt
new file mode 100644
index 0000000..2529b73
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_fizzbuzz.txt
@@ -0,0 +1,16 @@
+/* Test FizzBuzz-style patterns */
+fizzbuzz_test : n ->
+  when (n % 3) (n % 5) is
+    0 0 then "FizzBuzz"
+    0 _ then "Fizz"
+    _ 0 then "Buzz"
+    _ _ then n;
+
+result1 : fizzbuzz_test 15;
+result2 : fizzbuzz_test 3;
+result3 : fizzbuzz_test 5;
+result4 : fizzbuzz_test 7;
+..out result1;
+..out result2;
+..out result3;
+..out result4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_fizzbuzz_only.txt b/js/scripting-lang/scratch_tests/test_fizzbuzz_only.txt
new file mode 100644
index 0000000..2fd12ad
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_fizzbuzz_only.txt
@@ -0,0 +1,13 @@
+/* Test just the FizzBuzz part */
+
+/* Classic FizzBuzz using multi-value patterns with expressions */
+fizzbuzz : n ->
+  when (n % 3) (n % 5) is
+    0 0 then "FizzBuzz"
+    0 _ then "Fizz"
+    _ 0 then "Buzz"
+    _ _ then n;
+
+/* Test FizzBuzz implementation */
+fizzbuzz_15 : fizzbuzz 15;
+..out fizzbuzz_15; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_call_debug.txt b/js/scripting-lang/scratch_tests/test_func_call_debug.txt
new file mode 100644
index 0000000..33f39a7
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_call_debug.txt
@@ -0,0 +1,22 @@
+/* Debug test for function call evaluation */
+is_even : n -> n % 2 = 0;
+
+test_debug : n ->
+  when is_even n is
+    true then "even"
+    false then "odd";
+
+/* Test the function call separately */
+result1 : is_even 4;
+result2 : is_even 5;
+
+/* Test with explicit boolean comparison */
+test_explicit : n ->
+  when (is_even n = true) is
+    true then "even"
+    false then "odd";
+
+result3 : test_explicit 4;
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_call_debug2.txt b/js/scripting-lang/scratch_tests/test_func_call_debug2.txt
new file mode 100644
index 0000000..e272479
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_call_debug2.txt
@@ -0,0 +1,11 @@
+/* Debug test for function call evaluation in patterns */
+is_even : n -> n % 2 = 0;
+
+test_debug : n ->
+  when n is
+    is_even n then "function call result"
+    4 then "four"
+    _ then "other";
+
+result : test_debug 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_call_only.txt b/js/scripting-lang/scratch_tests/test_func_call_only.txt
new file mode 100644
index 0000000..b5bdf75
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_call_only.txt
@@ -0,0 +1,10 @@
+/* Function call test */
+is_even : n -> n % 2 = 0;
+
+test_func_call : n ->
+  when is_even n is
+    true then "even number"
+    false then "odd number";
+
+result : test_func_call 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_call_original.txt b/js/scripting-lang/scratch_tests/test_func_call_original.txt
new file mode 100644
index 0000000..0d4e8d0
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_call_original.txt
@@ -0,0 +1,10 @@
+/* Test the original failing case */
+is_even : n -> n % 2 = 0;
+
+test_original : n ->
+  when is_even n is
+    true then "even"
+    false then "odd";
+
+result : test_original 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_call_value.txt b/js/scripting-lang/scratch_tests/test_func_call_value.txt
new file mode 100644
index 0000000..1f222d8
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_call_value.txt
@@ -0,0 +1,12 @@
+/* Test what the function call evaluates to */
+is_even : n -> n % 2 = 0;
+
+test_value : n ->
+  when is_even n is
+    is_even n then "same value"
+    true then "true"
+    false then "false"
+    _ then "other";
+
+result : test_value 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_call_when.txt b/js/scripting-lang/scratch_tests/test_func_call_when.txt
new file mode 100644
index 0000000..469440a
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_call_when.txt
@@ -0,0 +1,10 @@
+/* Test function calls in when expressions */
+is_even : n -> n % 2 = 0;
+
+test_func_call : n ->
+  when is_even n is
+    true then "even number"
+    false then "odd number";
+
+result : test_func_call 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_calls_debug.txt b/js/scripting-lang/scratch_tests/test_func_calls_debug.txt
new file mode 100644
index 0000000..40f3437
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_calls_debug.txt
@@ -0,0 +1,17 @@
+/* Test function calls in when expressions */
+
+/* Helper functions for testing */
+is_even : n -> n % 2 = 0;
+
+/* Number classification using function calls in patterns */
+classify_number : n ->
+  when (is_even n) is
+    true then "even number"
+    false then "odd number";
+
+/* Test number classification */
+even_class : classify_number 4;
+odd_class : classify_number 7;
+
+..out even_class;
+..out odd_class; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_calls_only.txt b/js/scripting-lang/scratch_tests/test_func_calls_only.txt
new file mode 100644
index 0000000..f217d60
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_calls_only.txt
@@ -0,0 +1,17 @@
+/* Test just the function calls section */
+
+/* Helper functions for testing */
+is_even : n -> n % 2 = 0;
+
+/* Number classification using function calls in patterns */
+classify_number : n ->
+  when (is_even n) is
+    true then "even number"
+    false then "odd number";
+
+/* Test number classification */
+even_class : classify_number 4;
+odd_class : classify_number 7;
+
+..out even_class;
+..out odd_class; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_debug_detailed.txt b/js/scripting-lang/scratch_tests/test_func_debug_detailed.txt
new file mode 100644
index 0000000..fb96ce5
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_debug_detailed.txt
@@ -0,0 +1,24 @@
+/* Detailed debugging of function calls in when expressions */
+
+/* Helper functions for testing */
+is_even : n -> n % 2 = 0;
+
+/* Test the function directly */
+test1 : is_even 4;
+test2 : is_even 7;
+..out test1;
+..out test2;
+
+/* Number classification using function calls in patterns */
+classify_number : n ->
+  when (is_even n) is
+    true then "even number"
+    false then "odd number";
+
+/* Test number classification */
+even_class : classify_number 4;
+odd_class : classify_number 7;
+
+..out "Classification results:";
+..out even_class;
+..out odd_class; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_eval.txt b/js/scripting-lang/scratch_tests/test_func_eval.txt
new file mode 100644
index 0000000..8944b1f
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_eval.txt
@@ -0,0 +1,9 @@
+/* Test function call evaluation */
+is_even : n -> n % 2 = 0;
+
+result1 : is_even 4;
+result2 : is_even 5;
+result3 : is_even 0;
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_no_match.txt b/js/scripting-lang/scratch_tests/test_func_no_match.txt
new file mode 100644
index 0000000..ff55185
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_no_match.txt
@@ -0,0 +1,11 @@
+/* Test function call that should not match */
+is_even : n -> n % 2 = 0;
+
+test_no_match : n ->
+  when n is
+    is_even n then "function call result"
+    5 then "five"
+    _ then "other";
+
+result : test_no_match 5;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_pattern.txt b/js/scripting-lang/scratch_tests/test_func_pattern.txt
new file mode 100644
index 0000000..23f2888
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_pattern.txt
@@ -0,0 +1,11 @@
+/* Test function calls in patterns */
+is_even : n -> n % 2 = 0;
+
+test_func_pattern : n ->
+  when n is
+    (is_even n) then "function call result"
+    4 then "four"
+    _ then "other";
+
+result : test_func_pattern 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_func_return.txt b/js/scripting-lang/scratch_tests/test_func_return.txt
new file mode 100644
index 0000000..3a4bd5f
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_func_return.txt
@@ -0,0 +1,9 @@
+/* Test function call return value */
+is_even : n -> n % 2 = 0;
+
+result1 : is_even 4;
+result2 : is_even 5;
+result3 : is_even 0;
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_function_body.txt b/js/scripting-lang/scratch_tests/test_function_body.txt
new file mode 100644
index 0000000..7af35e5
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_function_body.txt
@@ -0,0 +1,15 @@
+/* Test multiple statements in function bodies */
+
+/* Test simple function */
+simple_func : n -> n;
+
+/* Test function with multiple statements */
+multi_func : n ->
+  a : n + 1;
+  b : a * 2;
+  b;
+
+result1 : simple_func 5;
+result2 : multi_func 5;
+..out result1;
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_function_calls_in_tables.txt b/js/scripting-lang/scratch_tests/test_function_calls_in_tables.txt
new file mode 100644
index 0000000..a7c991a
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_function_calls_in_tables.txt
@@ -0,0 +1,28 @@
+/* Test function calls in table literals */
+
+/* Test basic function calls */
+mod3 : n -> n % 3;
+mod5 : n -> n % 5;
+
+/* Test individual function calls */
+result1 : mod3 15;
+result2 : mod5 15;
+..out "mod3 15: " + result1;
+..out "mod5 15: " + result2;
+
+/* Test function calls in table */
+table1 : {mod3 15, mod5 15};
+..out "Table with function calls:";
+..out table1;
+
+/* Test with map */
+is_zero : x -> x = 0;
+mapped : map @is_zero table1;
+..out "Mapped table:";
+..out mapped;
+
+/* Test the complete divisibility function */
+divisibility : n -> map @is_zero {mod3 n, mod5 n};
+result : divisibility 15;
+..out "Divisibility result:";
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_listen_emit_basic.txt b/js/scripting-lang/scratch_tests/test_listen_emit_basic.txt
new file mode 100644
index 0000000..b135908
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_listen_emit_basic.txt
@@ -0,0 +1,16 @@
+/* Test basic ..listen and ..emit functionality */
+
+/* Test ..listen - should return placeholder state */
+state : ..listen;
+..out state;
+
+/* Test ..emit with simple value */
+..emit "Hello from script";
+
+/* Test ..emit with table */
+data : { message: "Test message", value: 42 };
+..emit data;
+
+/* Test ..emit with computed value */
+computed : 10 + 20;
+..emit computed; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_listen_emit_comprehensive.txt b/js/scripting-lang/scratch_tests/test_listen_emit_comprehensive.txt
new file mode 100644
index 0000000..79f1a98
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_listen_emit_comprehensive.txt
@@ -0,0 +1,48 @@
+/* Comprehensive test for ..listen and ..emit functionality */
+
+/* Test 1: Basic ..listen in assignment */
+state : ..listen;
+..out "State received:";
+..out state;
+
+/* Test 2: ..listen in when expression */
+result : when ..listen is
+    { status: "placeholder" } then "Placeholder state detected"
+    { status: "active" } then "Active state detected"
+    _ then "Unknown state";
+
+..out result;
+
+/* Test 3: ..emit with different data types */
+..emit "String value";
+..emit 42;
+..emit true;
+..emit { key: "value", number: 123 };
+
+/* Test 4: ..emit with computed expressions */
+computed_table : { a: 10, b: 20 };
+sum : computed_table.a + computed_table.b;
+..emit sum;
+
+/* Test 5: ..emit with function calls */
+doubled : t.map { 1, 2, 3, 4, 5 } (x -> x * 2);
+..emit doubled;
+
+/* Test 6: ..emit with conditional logic */
+condition : 10 > 5;
+message : when condition is
+    true then "Condition is true"
+    false then "Condition is false";
+..emit message;
+
+/* Test 7: ..emit with nested tables */
+nested : { 
+    user: { name: "Alice", age: 30 },
+    settings: { theme: "dark", notifications: true }
+};
+..emit nested;
+
+/* Test 8: Test that ..emit doesn't interfere with ..out */
+..out "This should appear via ..out";
+..emit "This should appear via ..emit";
+..out "Another ..out message"; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_listen_emit_final.txt b/js/scripting-lang/scratch_tests/test_listen_emit_final.txt
new file mode 100644
index 0000000..c735ab2
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_listen_emit_final.txt
@@ -0,0 +1,44 @@
+/* Final test for ..listen and ..emit functionality */
+
+/* Test 1: Basic ..listen in assignment */
+state : ..listen;
+..out "State received:";
+..out state;
+
+/* Test 2: ..listen in when expression with simple patterns */
+result : when ..listen is
+    "placeholder" then "Got placeholder"
+    "active" then "Got active"
+    _ then "Got something else";
+
+..out result;
+
+/* Test 3: ..emit with different data types */
+..emit "String value";
+..emit 42;
+..emit true;
+..emit { key: "value", number: 123 };
+
+/* Test 4: ..emit with computed expressions */
+computed_table : { a: 10, b: 20 };
+sum : computed_table.a + computed_table.b;
+..emit sum;
+
+/* Test 5: ..emit with conditional logic */
+condition : 10 > 5;
+message : when condition is
+    true then "Condition is true"
+    false then "Condition is false";
+..emit message;
+
+/* Test 6: ..emit with nested tables */
+nested : { 
+    user: { name: "Alice", age: 30 },
+    settings: { theme: "dark", notifications: true }
+};
+..emit nested;
+
+/* Test 7: Test that ..emit doesn't interfere with ..out */
+..out "This should appear via ..out";
+..emit "This should appear via ..emit";
+..out "Another ..out message"; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_listen_emit_simple.txt b/js/scripting-lang/scratch_tests/test_listen_emit_simple.txt
new file mode 100644
index 0000000..fce87da
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_listen_emit_simple.txt
@@ -0,0 +1,16 @@
+/* Simple test for ..listen and ..emit */
+
+/* Test 1: Basic ..listen */
+state : ..listen;
+..out state;
+
+/* Test 2: Basic ..emit */
+..emit "Hello";
+
+/* Test 3: ..listen in when expression with simple patterns */
+result : when ..listen is
+    "placeholder" then "Got placeholder"
+    "active" then "Got active"
+    _ then "Got something else";
+
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_logical_and_debug.txt b/js/scripting-lang/scratch_tests/test_logical_and_debug.txt
new file mode 100644
index 0000000..97251b7
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_logical_and_debug.txt
@@ -0,0 +1,26 @@
+/* Test logicalAnd function directly */
+
+/* Test individual comparisons */
+test1 : (-5) >= 0;  /* Should be false */
+test2 : (-5) <= 120; /* Should be true */
+
+/* Test logicalAnd with these values */
+result1 : logicalAnd test1 test2;  /* false && true = false */
+result2 : logicalAnd test2 test1;  /* true && false = false */
+
+/* Test the original expression step by step */
+step1 : (-5) >= 0;  /* false */
+step2 : (-5) <= 120; /* true */
+step3 : logicalAnd step1 step2; /* false && true = false */
+
+/* Test with parentheses */
+parens_test : logicalAnd ((-5) >= 0) ((-5) <= 120);
+
+..out test1;
+..out test2;
+..out result1;
+..out result2;
+..out step1;
+..out step2;
+..out step3;
+..out parens_test; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_minimal_enhanced.txt b/js/scripting-lang/scratch_tests/test_minimal_enhanced.txt
new file mode 100644
index 0000000..e4fe6d2
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_minimal_enhanced.txt
@@ -0,0 +1,32 @@
+/* Minimal enhanced case statements test */
+
+/* FizzBuzz */
+fizzbuzz : n ->
+  when (n % 3) (n % 5) is
+    0 0 then "FizzBuzz"
+    0 _ then "Fizz"
+    _ 0 then "Buzz"
+    _ _ then n;
+
+/* Table access */
+admin_user : {role: "admin"};
+access_level : user ->
+  when user.role is
+    "admin" then "full access"
+    _ then "no access";
+
+/* Function calls */
+is_even : n -> n % 2 = 0;
+classify_number : n ->
+  when (is_even n) is
+    true then "even"
+    false then "odd";
+
+/* Test and output */
+result1 : fizzbuzz 15;
+result2 : access_level admin_user;
+result3 : classify_number 4;
+
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_minimal_enhanced_case.txt b/js/scripting-lang/scratch_tests/test_minimal_enhanced_case.txt
new file mode 100644
index 0000000..082c194
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_minimal_enhanced_case.txt
@@ -0,0 +1,11 @@
+/* Minimal test for enhanced case statements */
+
+/* Test basic function */
+fizzbuzz : n -> n;
+
+/* Test basic when expression */
+result : when fizzbuzz 5 is
+  5 then "works"
+  _ then "fail";
+
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_minimal_when.txt b/js/scripting-lang/scratch_tests/test_minimal_when.txt
new file mode 100644
index 0000000..fdb5d33
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_minimal_when.txt
@@ -0,0 +1,9 @@
+/* Minimal test for when expression */
+test_minimal : n ->
+  when n is
+    0 then "zero"
+    1 then "one"
+    _ then "other";
+
+result : test_minimal 5;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_modulo_in_when.txt b/js/scripting-lang/scratch_tests/test_modulo_in_when.txt
new file mode 100644
index 0000000..4b2b023
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_modulo_in_when.txt
@@ -0,0 +1,30 @@
+/* Test modulo operator in when expressions */
+
+/* Test basic modulo */
+test1 : 15 % 3;
+..out test1;
+
+/* Test modulo in when expression */
+test2 : when 15 % 3 is
+  0 then "divisible by 3"
+  _ then "not divisible by 3";
+
+..out test2;
+
+/* Test multiple values in when expression */
+test3 : when 15 % 3 15 % 5 is
+  0 0 then "divisible by both"
+  0 _ then "divisible by 3 only"
+  _ 0 then "divisible by 5 only"
+  _ _ then "divisible by neither";
+
+..out test3;
+
+/* Test modulo with equals function in when expression */
+test4 : when equals (15 % 3) 0 equals (15 % 5) 0 is
+  true true then "divisible by both"
+  true false then "divisible by 3 only"
+  false true then "divisible by 5 only"
+  false false then "divisible by neither";
+
+..out test4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_multi_validation_debug.txt b/js/scripting-lang/scratch_tests/test_multi_validation_debug.txt
new file mode 100644
index 0000000..c252b54
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_multi_validation_debug.txt
@@ -0,0 +1,13 @@
+/* Test multi-value validation pattern */
+
+/* Multi-field validation using function calls */
+validate_user : name age ->
+  when (name != "") (age >= 0 and age <= 120) is
+    true true then "valid user"
+    true false then "invalid age"
+    false true then "invalid name"
+    false false then "invalid user";
+
+/* Test user validation */
+valid_user : validate_user "Alice" 30;
+..out valid_user; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_multi_validation_only.txt b/js/scripting-lang/scratch_tests/test_multi_validation_only.txt
new file mode 100644
index 0000000..f330ffe
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_multi_validation_only.txt
@@ -0,0 +1,13 @@
+/* Test just the multi-value validation pattern */
+
+/* Multi-field validation using function calls */
+validate_user : name age ->
+  when (name != "") (age >= 0 and age <= 120) is
+    true true then "valid user"
+    true false then "invalid age"
+    false true then "invalid name"
+    false false then "invalid user";
+
+/* Test user validation */
+valid_user : validate_user "Alice" 30;
+..out valid_user; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_multi_validation_simple.txt b/js/scripting-lang/scratch_tests/test_multi_validation_simple.txt
new file mode 100644
index 0000000..a26a72a
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_multi_validation_simple.txt
@@ -0,0 +1,13 @@
+/* Test simpler multi-value validation pattern */
+
+/* Test with simple boolean expressions */
+validate_user : name age ->
+  when (name != "") (age > 0) is
+    true true then "valid user"
+    true false then "invalid age"
+    false true then "invalid name"
+    false false then "invalid user";
+
+/* Test user validation */
+valid_user : validate_user "Alice" 30;
+..out valid_user; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_multi_value_expr.txt b/js/scripting-lang/scratch_tests/test_multi_value_expr.txt
new file mode 100644
index 0000000..cbc3233
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_multi_value_expr.txt
@@ -0,0 +1,10 @@
+/* Test multi-value patterns with expressions */
+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";
+
+result : test_multi_expr 4 6;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_multiple_values_parens.txt b/js/scripting-lang/scratch_tests/test_multiple_values_parens.txt
new file mode 100644
index 0000000..601ca43
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_multiple_values_parens.txt
@@ -0,0 +1,29 @@
+/* Test multiple values with parentheses in when expressions */
+
+/* Test simple multiple values */
+test1 : when 5 3 is
+  5 3 then "simple multiple values work"
+  _ _ then "simple multiple values don't work";
+
+..out test1;
+
+/* Test multiple values with parentheses */
+test2 : when (5) (3) is
+  5 3 then "parenthesized multiple values work"
+  _ _ then "parenthesized multiple values don't work";
+
+..out test2;
+
+/* Test multiple values with expressions in parentheses */
+test3 : when (5 + 2) (3 + 0) is
+  7 3 then "expressions in parentheses work"
+  _ _ then "expressions in parentheses don't work";
+
+..out test3;
+
+/* Test FizzBuzz-style multiple values */
+test4 : when (15 % 3) (15 % 5) is
+  0 0 then "FizzBuzz-style multiple values work"
+  _ _ then "FizzBuzz-style multiple values don't work";
+
+..out test4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_nested_only.txt b/js/scripting-lang/scratch_tests/test_nested_only.txt
new file mode 100644
index 0000000..f3857fc
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_nested_only.txt
@@ -0,0 +1,15 @@
+/* Test just the nested when expressions */
+
+/* Ensure backward compatibility with nested when expressions */
+nested_classify : x y ->
+  when x is
+    0 then when y is
+      0 then "origin"
+      _ then "on y-axis"
+    _ then when y is
+      0 then "on x-axis"
+      _ then "general position";
+
+/* Test nested when expressions */
+nested1 : nested_classify 0 0;
+..out nested1; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_parens_disambiguation.txt b/js/scripting-lang/scratch_tests/test_parens_disambiguation.txt
new file mode 100644
index 0000000..8863d8b
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_parens_disambiguation.txt
@@ -0,0 +1,29 @@
+/* Test if parentheses can help disambiguate complex expressions */
+
+/* Test modulo with parentheses */
+test1 : when (15 % 3) is
+  0 then "modulo in parentheses works"
+  _ then "modulo in parentheses doesn't work";
+
+..out test1;
+
+/* Test equals with parentheses */
+test2 : when (5 = 5) is
+  true then "equals in parentheses works"
+  _ then "equals in parentheses doesn't work";
+
+..out test2;
+
+/* Test complex expression with parentheses */
+test3 : when ((15 % 3) = 0) is
+  true then "complex expression in parentheses works"
+  _ then "complex expression in parentheses doesn't work";
+
+..out test3;
+
+/* Test multiple values with parentheses */
+test4 : when (15 % 3) (15 % 5) is
+  0 0 then "multiple values with parentheses work"
+  _ _ then "multiple values with parentheses don't work";
+
+..out test4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_parens_in_when.txt b/js/scripting-lang/scratch_tests/test_parens_in_when.txt
new file mode 100644
index 0000000..4b441b4
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_parens_in_when.txt
@@ -0,0 +1,22 @@
+/* Test parentheses in when expressions */
+
+/* Test simple parentheses */
+test1 : when (5) is
+  5 then "parentheses work"
+  _ then "parentheses don't work";
+
+..out test1;
+
+/* Test parentheses with arithmetic */
+test2 : when (5 + 3) is
+  8 then "arithmetic in parentheses works"
+  _ then "arithmetic in parentheses doesn't work";
+
+..out test2;
+
+/* Test parentheses with function calls */
+test3 : when (equals 5 5) is
+  true then "function call in parentheses works"
+  _ then "function call in parentheses doesn't work";
+
+..out test3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_parens_multiple.txt b/js/scripting-lang/scratch_tests/test_parens_multiple.txt
new file mode 100644
index 0000000..84592b7
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_parens_multiple.txt
@@ -0,0 +1,37 @@
+/* Test parentheses with multiple values in when expressions */
+
+/* Test with parentheses around expressions */
+compare_parens : x y -> 
+  when (x) (y) is
+    0 0 then "both zero"
+    0 _ then "x is zero"
+    _ 0 then "y is zero"
+    _ _ then "neither zero";
+
+test1 : compare_parens 0 0;
+test2 : compare_parens 0 5;
+test3 : compare_parens 5 0;
+test4 : compare_parens 5 5;
+
+..out test1;
+..out test2;
+..out test3;
+..out test4;
+
+/* Test with arithmetic expressions in parentheses */
+compare_math : x y -> 
+  when (x + 0) (y + 0) is
+    0 0 then "both zero"
+    0 _ then "x is zero"
+    _ 0 then "y is zero"
+    _ _ then "neither zero";
+
+test5 : compare_math 0 0;
+test6 : compare_math 0 5;
+test7 : compare_math 5 0;
+test8 : compare_math 5 5;
+
+..out test5;
+..out test6;
+..out test7;
+..out test8; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_pattern_debug.txt b/js/scripting-lang/scratch_tests/test_pattern_debug.txt
new file mode 100644
index 0000000..ef8b676
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_pattern_debug.txt
@@ -0,0 +1,14 @@
+/* Test pattern matching with boolean values */
+
+/* Test direct boolean matching */
+test_bool : value ->
+  when value is
+    true then "true matched"
+    false then "false matched"
+    _ then "wildcard matched";
+
+result1 : test_bool true;
+result2 : test_bool false;
+
+..out result1;
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_predicate_functions.txt b/js/scripting-lang/scratch_tests/test_predicate_functions.txt
new file mode 100644
index 0000000..e1cba80
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_predicate_functions.txt
@@ -0,0 +1,35 @@
+/* Test predicate functions */
+
+/* Test basic predicate functions */
+is_fizzbuzz : n -> (n % 3 = 0) and (n % 5 = 0);
+is_fizz : n -> n % 3 = 0;
+is_buzz : n -> n % 5 = 0;
+
+/* Test the functions */
+test1 : is_fizzbuzz 15;
+test2 : is_fizz 3;
+test3 : is_buzz 5;
+test4 : is_fizzbuzz 7;
+
+..out test1;
+..out test2;
+..out test3;
+..out test4;
+
+/* Test simple when with boolean */
+simple_test : n ->
+  when true is
+    true then "true"
+    _ then "false";
+
+result1 : simple_test 15;
+..out result1;
+
+/* Test function call in when */
+func_test : n ->
+  when is_fizzbuzz n is
+    true then "FizzBuzz"
+    _ then n;
+
+result2 : func_test 15;
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_run_function.js b/js/scripting-lang/scratch_tests/test_run_function.js
new file mode 100644
index 0000000..c79f5e8
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_run_function.js
@@ -0,0 +1,24 @@
+/**
+ * Test the run function directly
+ */
+
+import { run } from '../lang.js';
+
+const scriptContent = `
+/* Simple test script */
+
+/* Get current state */
+state : ..listen;
+
+/* Emit the state */
+..emit state;
+`;
+
+try {
+    console.log('Testing run function...');
+    const result = run(scriptContent, {}, null);
+    console.log('Result:', result);
+} catch (error) {
+    console.error('Error:', error);
+    console.error('Stack:', error.stack);
+} 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_and.txt b/js/scripting-lang/scratch_tests/test_simple_and.txt
new file mode 100644
index 0000000..fbf2edf
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_and.txt
@@ -0,0 +1,14 @@
+/* Test simple logicalAnd */
+
+/* Simple boolean values */
+true_val : true;
+false_val : false;
+
+/* Test logicalAnd with simple values */
+result1 : logicalAnd true_val false_val;
+result2 : logicalAnd false_val true_val;
+result3 : logicalAnd true_val true_val;
+
+..out result1;
+..out result2;
+..out result3; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_fizzbuzz.txt b/js/scripting-lang/scratch_tests/test_simple_fizzbuzz.txt
new file mode 100644
index 0000000..0b6cf39
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_fizzbuzz.txt
@@ -0,0 +1,43 @@
+/* Simple FizzBuzz test */
+
+/* Test basic modulo */
+test1 : 15 % 3;
+test2 : 15 % 5;
+..out test1;
+..out test2;
+
+/* Test basic when with modulo */
+test3 : when 15 % 3 is
+  0 then "divisible by 3"
+  _ then "not divisible by 3";
+..out test3;
+
+/* Test simple function */
+simple_test : n -> n;
+
+result1 : simple_test 3;
+..out result1;
+
+/* Test when inside function */
+when_test : n ->
+  when n is
+    3 then "three"
+    _ then n;
+
+result2 : when_test 3;
+..out result2;
+
+/* Test modulo in function */
+modulo_test : n -> n % 3;
+
+result3 : modulo_test 15;
+..out result3;
+
+/* Test greater than in when */
+greater_test : n ->
+  when n > 0 is
+    true then "positive"
+    _ then "non-positive";
+
+result4 : greater_test 5;
+..out result4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_func_call.txt b/js/scripting-lang/scratch_tests/test_simple_func_call.txt
new file mode 100644
index 0000000..06ec7cd
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_func_call.txt
@@ -0,0 +1,10 @@
+/* Test with a simpler function call */
+id : x -> x;
+
+test_simple : n ->
+  when id n is
+    n then "same"
+    _ then "different";
+
+result : test_simple 4;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_harness.txt b/js/scripting-lang/scratch_tests/test_simple_harness.txt
new file mode 100644
index 0000000..6d1381b
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_harness.txt
@@ -0,0 +1,7 @@
+/* Simple test script */
+
+/* Get current state */
+state : ..listen;
+
+/* Emit the state */
+..emit state; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_multiple.txt b/js/scripting-lang/scratch_tests/test_simple_multiple.txt
new file mode 100644
index 0000000..fc3ee32
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_multiple.txt
@@ -0,0 +1,8 @@
+/* Test simple multiple values in when expressions */
+
+/* Test simple multiple values */
+test1 : when 5 3 is
+  5 3 then "simple multiple values work"
+  _ _ then "simple multiple values don't work";
+
+..out test1; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_verification.txt b/js/scripting-lang/scratch_tests/test_simple_verification.txt
new file mode 100644
index 0000000..2abdc0f
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_verification.txt
@@ -0,0 +1,51 @@
+/* Simple verification test for enhanced case statements */
+
+/* Test 1: Basic table creation */
+basic : {1, 2, 3};
+..out "Basic table:";
+..out basic;
+
+/* Test 2: Auto-indexed table with expressions */
+expr : {5 % 3, 5 % 5};
+..out "Expression table:";
+..out expr;
+
+/* Test 3: Map with equals 0 */
+mapped : map @(equals 0) {15 % 3, 15 % 5};
+..out "Mapped table:";
+..out mapped;
+
+/* Test 4: Simple table pattern matching */
+test_table : {1: true, 2: false};
+result : when test_table is
+    {1: true, 2: true} then "both true"
+    {1: true, 2: false} then "first true"
+    {1: false, 2: true} then "second true"
+    {1: false, 2: false} then "both false";
+..out "Pattern match result:";
+..out result;
+
+/* Test 5: FizzBuzz divisibility function */
+divisibility : n -> map @(equals 0) {n % 3, n % 5};
+div_15 : divisibility 15;
+..out "Divisibility for 15:";
+..out div_15;
+
+/* Test 6: Complete FizzBuzz */
+fizzbuzz : n ->
+  when divisibility n is
+    {1: true, 2: true} then "FizzBuzz"
+    {1: true, 2: false} then "Fizz"
+    {1: false, 2: true} then "Buzz"
+    {1: false, 2: false} then n;
+
+fizz_15 : fizzbuzz 15;
+fizz_3 : fizzbuzz 3;
+fizz_5 : fizzbuzz 5;
+fizz_7 : fizzbuzz 7;
+
+..out "FizzBuzz results:";
+..out "15: " + fizz_15;
+..out "3: " + fizz_3;
+..out "5: " + fizz_5;
+..out "7: " + fizz_7; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_simple_when_equals.txt b/js/scripting-lang/scratch_tests/test_simple_when_equals.txt
new file mode 100644
index 0000000..885091b
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_simple_when_equals.txt
@@ -0,0 +1,17 @@
+/* Simple test for when expressions with equals */
+
+/* Test basic when with equals */
+test1 : when 5 = 5 is
+  true then "equal"
+  _ then "not equal";
+
+..out test1;
+
+/* Test multiple values with different patterns */
+test2 : when 5 = 5 3 = 3 is
+  1 1 then "both equal"
+  1 0 then "first equal"
+  0 1 then "second equal"
+  0 0 then "neither equal";
+
+..out test2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_table_access_debug.txt b/js/scripting-lang/scratch_tests/test_table_access_debug.txt
new file mode 100644
index 0000000..e4c613a
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_table_access_debug.txt
@@ -0,0 +1,15 @@
+/* Test table access in when expressions */
+
+/* User data for testing */
+admin_user : {role: "admin", level: 5, name: "Alice"};
+
+/* Access control using table access in patterns */
+access_level : user ->
+  when user.role is
+    "admin" then "full access"
+    "user" then "limited access"
+    _ then "no access";
+
+/* Test access control */
+admin_access : access_level admin_user;
+..out admin_access; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt b/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt
new file mode 100644
index 0000000..4817b23
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt
@@ -0,0 +1,22 @@
+/* Test table access in function definitions */
+
+/* Test basic table access */
+user : {role: "admin", active: true};
+test1 : user.role;
+test2 : user.active;
+..out test1;
+..out test2;
+
+/* Test table access in function */
+get_role : user -> user.role;
+test3 : get_role user;
+..out test3;
+
+/* Test table access inside when in function */
+classify_user : user ->
+  when user.role is
+    "admin" then "admin"
+    _ then "user";
+
+test4 : classify_user user;
+..out test4; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_table_access_only.txt b/js/scripting-lang/scratch_tests/test_table_access_only.txt
new file mode 100644
index 0000000..0874c0f
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_table_access_only.txt
@@ -0,0 +1,15 @@
+/* Test just the table access part */
+
+/* User data for testing */
+admin_user : {role: "admin", level: 5, name: "Alice"};
+
+/* Access control using table access in patterns */
+access_level : user ->
+  when user.role is
+    "admin" then "full access"
+    "user" then "limited access"
+    _ then "no access";
+
+/* Test access control */
+admin_access : access_level admin_user;
+..out admin_access; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_table_access_when.txt b/js/scripting-lang/scratch_tests/test_table_access_when.txt
new file mode 100644
index 0000000..4161b19
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_table_access_when.txt
@@ -0,0 +1,11 @@
+/* Test 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";
+
+result : test_table_access user;
+..out result; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_when_pattern_matching.txt b/js/scripting-lang/scratch_tests/test_when_pattern_matching.txt
new file mode 100644
index 0000000..a9efad0
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_when_pattern_matching.txt
@@ -0,0 +1,25 @@
+/* Test when expression pattern matching with tables */
+
+/* Test 1: Simple table pattern matching */
+test_value : { status: "placeholder", message: "test" };
+
+result1 : when test_value is
+    { status: "placeholder" } then "Pattern 1 matched"
+    { status: "active" } then "Pattern 2 matched"
+    _ then "No pattern matched";
+
+..out "Result 1:";
+..out result1;
+
+/* Test 2: ..listen pattern matching */
+state : ..listen;
+..out "State:";
+..out state;
+
+result2 : when state is
+    { status: "placeholder" } then "Placeholder pattern matched"
+    { status: "active" } then "Active pattern matched"
+    _ then "No pattern matched";
+
+..out "Result 2:";
+..out result2; 
\ No newline at end of file
diff --git a/js/scripting-lang/scratch_tests/test_working_multiple.txt b/js/scripting-lang/scratch_tests/test_working_multiple.txt
new file mode 100644
index 0000000..66c796f
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_working_multiple.txt
@@ -0,0 +1,18 @@
+/* Test multiple values using working syntax */
+
+compare : x y -> 
+  when x y is
+    0 0 then "both zero"
+    0 _ then "x is zero"
+    _ 0 then "y is zero"
+    _ _ then "neither zero";
+
+test1 : compare 0 0;
+test2 : compare 0 5;
+test3 : compare 5 0;
+test4 : compare 5 5;
+
+..out test1;
+..out test2;
+..out test3;
+..out test4; 
\ No newline at end of file