about summary refs log tree commit diff stats
path: root/js/scripting-lang/c/tests/06_function_definitions.txt
blob: b0e591ff2611120d01a6c2ef95d89b68003a2509 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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";