From dcfdc053cb5f9fb4d5eac0a2233c75126b7a8188 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Wed, 14 Jan 2026 23:59:54 +0000 Subject: Added some of the tests. --- tests/functions/test_lambda_arrow.zc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/functions/test_lambda_arrow.zc (limited to 'tests/functions/test_lambda_arrow.zc') diff --git a/tests/functions/test_lambda_arrow.zc b/tests/functions/test_lambda_arrow.zc new file mode 100644 index 0000000..c976ecf --- /dev/null +++ b/tests/functions/test_lambda_arrow.zc @@ -0,0 +1,20 @@ + +fn compute(op: fn(I32, I32) -> I32, a: I32, b: I32) -> I32 { + return op(a, b); +} + +test "test_lambda_arrow" { + var doubler = x -> x * 2; + var res1 = doubler(5); + "doubler(5) = {res1}"; + if res1 != 10 { exit(1); } + + var add = (x, y) -> x + y; + var res2 = add(10, 20); + "add(10, 20) = {res2}"; + if res2 != 30 { exit(1); } + + var res3 = compute((a, b) -> a * b, 3, 4); + "compute((a, b) -> a * b, 3, 4) = {res3}"; + if res3 != 12 { exit(1); } +} -- cgit v1.2.3