about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/06_function_definitions.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/06_function_definitions.txt')
-rw-r--r--js/scripting-lang/tests/06_function_definitions.txt32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/06_function_definitions.txt b/js/scripting-lang/tests/06_function_definitions.txt
new file mode 100644
index 0000000..a34da72
--- /dev/null
+++ b/js/scripting-lang/tests/06_function_definitions.txt
@@ -0,0 +1,32 @@
+/* Unit Test: Function Definitions */
+/* Tests: Function syntax, parameters, calls */
+
+/* Basic function definitions */
+add_func : x y -> x + y;
+multiply_func : x y -> x * y;
+double_func : x -> x * 2;
+square_func : x -> x * x;
+identity_func : x -> x;
+
+/* Test function calls */
+result1 : add_func 3 4;
+result2 : multiply_func 5 6;
+result3 : double_func 8;
+result4 : square_func 4;
+result5 : identity_func 42;
+
+/* Test results */
+..assert result1 = 7;
+..assert result2 = 30;
+..assert result3 = 16;
+..assert result4 = 16;
+..assert result5 = 42;
+
+/* Test function calls with parentheses */
+result6 : add_func (3 + 2) (4 + 1);
+result7 : multiply_func (double_func 3) (square_func 2);
+
+..assert result6 = 10;
+..assert result7 = 24;
+
+..out "Function definitions test completed"; 
\ No newline at end of file