about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/07_case_expressions.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/07_case_expressions.txt')
-rw-r--r--js/scripting-lang/tests/07_case_expressions.txt32
1 files changed, 16 insertions, 16 deletions
diff --git a/js/scripting-lang/tests/07_case_expressions.txt b/js/scripting-lang/tests/07_case_expressions.txt
index d0ed2fe..ccc447c 100644
--- a/js/scripting-lang/tests/07_case_expressions.txt
+++ b/js/scripting-lang/tests/07_case_expressions.txt
@@ -3,16 +3,16 @@
 
 /* Basic case expressions */
 factorial : n -> 
-  case n of
-    0 : 1
-    _ : n * (factorial (n - 1));
+  when n is
+    0 then 1
+    _ then n * (@factorial (n - 1));
 
 grade : score -> 
-  case score of
-    90 : "A"
-    80 : "B"
-    70 : "C"
-    _  : "F";
+  when score is
+    score >= 90 then "A"
+    score >= 80 then "B"
+    score >= 70 then "C"
+    _  then "F";
 
 /* Test case expressions */
 fact5 : factorial 5;
@@ -22,17 +22,17 @@ grade3 : grade 65;
 
 /* Test results */
 ..assert fact5 = 120;
-..assert grade1 = "A";
-..assert grade2 = "B";
-..assert grade3 = "F";
+..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 -> 
-  case x y of
-    0 0 : "both zero"
-    0 _ : "x is zero"
-    _ 0 : "y is zero"
-    _ _ : "neither zero";
+  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;