summaryrefslogtreecommitdiffhomepage
path: root/tests/00_syntax/15_function_declarations
diff options
context:
space:
mode:
Diffstat (limited to 'tests/00_syntax/15_function_declarations')
-rw-r--r--tests/00_syntax/15_function_declarations28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/00_syntax/15_function_declarations b/tests/00_syntax/15_function_declarations
index 1ed6f83..f02f90a 100644
--- a/tests/00_syntax/15_function_declarations
+++ b/tests/00_syntax/15_function_declarations
@@ -96,3 +96,31 @@ function variadic_2(...args) { ... }
]), "\n");
%}
-- End --
+
+
+Complementary to the "rest" argument syntax, the spread operator may be
+used in function call arguments to pass arrays of values as argument list.
+
+-- Expect stdout --
+[ 1, 2, 3, 4, 5, 6 ]
+[ 4, 5, 6, 1, 2, 3 ]
+[ 1, 2, 3, 1, 2, 3 ]
+[ 1, 2, 3 ]
+-- End --
+
+-- Testcase --
+{%
+ arr = [ 1, 2, 3 ];
+
+ function test(...args) {
+ return args;
+ }
+
+ print(join("\n", [
+ test(...arr, 4, 5, 6),
+ test(4, 5, 6, ...arr),
+ test(...arr, ...arr),
+ test(...arr)
+ ]), "\n");
+%}
+-- End --