From 940a89bd5cc1a04dbff4379b02d559982b4febd4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 3 Nov 2020 23:43:01 +0100 Subject: tests: add illegal syntax tests for rest arguments Signed-off-by: Jo-Philipp Wich --- tests/00_syntax/15_function_declarations | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/00_syntax/15_function_declarations b/tests/00_syntax/15_function_declarations index f02f90a..4257dd6 100644 --- a/tests/00_syntax/15_function_declarations +++ b/tests/00_syntax/15_function_declarations @@ -124,3 +124,41 @@ used in function call arguments to pass arrays of values as argument list. ]), "\n"); %} -- End -- + + +Rest arguments may be only used once in a declaration and they must always +be the last item in the argument list. + +-- Expect stderr -- +Syntax error: Unexpected token +Expecting ')' +In line 2, byte 26: + + ` function illegal(...args, ...args2) {}` + Near here ------------------^ + + +-- End -- + +-- Testcase -- +{% + function illegal(...args, ...args2) {} +%} +-- End -- + +-- Expect stderr -- +Syntax error: Unexpected token +Expecting ')' +In line 2, byte 26: + + ` function illegal(...args, a, b) {}` + Near here ------------------^ + + +-- End -- + +-- Testcase -- +{% + function illegal(...args, a, b) {} +%} +-- End -- -- cgit v1.2.3