From 50ab73cf1e34ed951e43c2e5056695d5d3c82053 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Fri, 26 Sep 2025 08:30:31 -0700 Subject: [PATCH] Feat: Add test for function declaration and invocation --- test/src/functions.hi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/src/functions.hi diff --git a/test/src/functions.hi b/test/src/functions.hi new file mode 100644 index 0000000..8c0aa86 --- /dev/null +++ b/test/src/functions.hi @@ -0,0 +1,26 @@ +// implicit return +add: (a, b) { + a + b +} +_(add(5, 3)) + +// explicit return +greet: (name) { + ^ "Hello, " + name + _("this should not print") +} +_(greet("Master")) + +// arrow function +multiply: (a, b) => a * b +_(multiply(2, 4)) + +// block with side effects and return +calculator: { + add: (a, b) => a + b, + subtract: (a, b) { + _("Subtracting...") + a - b + } +} +_(calculator.subtract(10, 3))