about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_function_declaration.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_function_declaration.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_function_declaration.txt37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_function_declaration.txt b/js/scripting-lang/scratch_tests/test_function_declaration.txt
new file mode 100644
index 0000000..90c1594
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_function_declaration.txt
@@ -0,0 +1,37 @@
+/* Test FunctionDeclaration behavior */
+
+// Test 1: Regular function declaration
+test_func : x y -> x + y;
+
+// Test 2: Function declaration with when expression
+test_when : x -> when x is
+    0 then "zero"
+    _ then "other"
+;
+
+// Test 3: Function declaration in table
+table_func : {
+    add: x y -> x + y,
+    classify: x -> when x is
+        0 then "zero"
+        _ then "other"
+};
+
+// Output tests
+..out "=== FUNCTION DECLARATION TEST ===";
+
+..out "Regular function:";
+result1 : test_func 5 3;
+..out result1;
+
+..out "When function:";
+result2 : test_when 0;
+..out result2;
+result3 : test_when 5;
+..out result3;
+
+..out "Table functions:";
+result4 : table_func.add 10 20;
+..out result4;
+result5 : table_func.classify 0;
+..out result5; 
\ No newline at end of file