diff options
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_pattern_part3.txt')
-rw-r--r-- | js/scripting-lang/scratch_tests/test_pattern_part3.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_pattern_part3.txt b/js/scripting-lang/scratch_tests/test_pattern_part3.txt new file mode 100644 index 0000000..3c32b90 --- /dev/null +++ b/js/scripting-lang/scratch_tests/test_pattern_part3.txt @@ -0,0 +1,28 @@ +/* Integration Test: Pattern Matching */ +/* Combines: case expressions, functions, recursion, complex patterns */ + +..out "=== Integration Test: Pattern Matching ==="; + +/* Recursive factorial with case expressions */ +factorial : n -> + when n is + 0 then 1 + _ then n * (factorial (n - 1)); + +/* Pattern matching with multiple parameters */ +classify : x y -> + when x y is + 0 0 then "both zero" + 0 _ then "x is zero" + _ 0 then "y is zero" + _ _ then when x is + 0 then "x is zero (nested)" + _ then when y is + 0 then "y is zero (nested)" + _ then "neither zero"; + +/* Test factorial */ +fact5 : factorial 5; +fact3 : factorial 3; + +..out "test calls created successfully"; \ No newline at end of file |