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