about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_enhanced_case_final.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_enhanced_case_final.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_enhanced_case_final.txt62
1 files changed, 62 insertions, 0 deletions
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