summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/00_syntax/19_arrow_functions
diff options
context:
space:
mode:
Diffstat (limited to 'tests/custom/00_syntax/19_arrow_functions')
-rw-r--r--tests/custom/00_syntax/19_arrow_functions25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/custom/00_syntax/19_arrow_functions b/tests/custom/00_syntax/19_arrow_functions
index 8dcce6c..761705b 100644
--- a/tests/custom/00_syntax/19_arrow_functions
+++ b/tests/custom/00_syntax/19_arrow_functions
@@ -38,7 +38,7 @@ test
// parentheses may be omitted if arrow function takes only one argument
test4_fn = a => {
- a * 2;
+ return a * 2;
};
// curly braces may be omitted if function body is a single expression
@@ -122,3 +122,26 @@ In line 2, byte 10:
(a + 1) => { print("test\n") }
%}
-- End --
+
+
+Arrow functions consisting of a single expression implicitly return the expression
+results. Arrow functions having a statement block as body do not return any result
+by default but may return explictly.
+
+-- Expect stdout --
+[
+ 4,
+ null,
+ 4
+]
+-- End --
+
+-- Testcase --
+{%
+ printf("%.J\n", [
+ (() => 2 * 2)(),
+ (() => { 2 * 2 })(),
+ (() => { return 2 * 2 })()
+ ]);
+%}
+-- End --