about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_at_operator.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_at_operator.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_at_operator.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_at_operator.txt b/js/scripting-lang/scratch_tests/test_at_operator.txt
new file mode 100644
index 0000000..bd663bd
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_at_operator.txt
@@ -0,0 +1,21 @@
+/* Test the @ operator for function references */
+
+f : x -> x * 2;
+g : x -> x + 1;
+
+/* Test 1: Function reference in when expression */
+abs : x -> when x is
+    x < 0 then -x
+    _ then x;
+
+/* Test 2: Using @ operator to reference a function */
+result1 : @f 5;  /* Should be apply(f, 5) = 10 */
+
+/* Test 3: Function reference in when expression */
+test : x -> when x is
+    @f then "f was called"
+    @g then "g was called"
+    _ then "neither";
+
+/* Test 4: Function reference as argument */
+result2 : @f;  /* Should return the function f itself */ 
\ No newline at end of file