diff options
Diffstat (limited to 'js/scripting-lang/baba-yaga-c/tests/07_case_expressions.txt')
-rw-r--r-- | js/scripting-lang/baba-yaga-c/tests/07_case_expressions.txt | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/js/scripting-lang/baba-yaga-c/tests/07_case_expressions.txt b/js/scripting-lang/baba-yaga-c/tests/07_case_expressions.txt deleted file mode 100644 index ccc447c..0000000 --- a/js/scripting-lang/baba-yaga-c/tests/07_case_expressions.txt +++ /dev/null @@ -1,47 +0,0 @@ -/* Unit Test: Case Expressions */ -/* Tests: Pattern matching, wildcards, nested cases */ - -/* Basic case expressions */ -factorial : n -> - when n is - 0 then 1 - _ then n * (@factorial (n - 1)); - -grade : score -> - when score is - score >= 90 then "A" - score >= 80 then "B" - score >= 70 then "C" - _ then "F"; - -/* Test case expressions */ -fact5 : factorial 5; -grade1 : grade 95; -grade2 : grade 85; -grade3 : grade 65; - -/* Test results */ -..assert fact5 = 120; -..assert grade1 = "A"; /* 95 >= 90, so matches first case */ -..assert grade2 = "B"; /* 85 >= 80, so matches second case */ -..assert grade3 = "F"; /* 65 < 70, so falls through to wildcard */ - -/* Multi-parameter case expressions */ -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; - -..assert test1 = "both zero"; -..assert test2 = "x is zero"; -..assert test3 = "y is zero"; -..assert test4 = "neither zero"; - -..out "Case expressions test completed"; \ No newline at end of file |