summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js')
-rw-r--r--js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js104
1 files changed, 104 insertions, 0 deletions
diff --git a/js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js b/js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js
new file mode 100644
index 000000000..6dc8d8621
--- /dev/null
+++ b/js/src/tests/ecma_7/AsyncFunctions/syntax-arrow.js
@@ -0,0 +1,104 @@
+var BUGNUMBER = 1185106;
+var summary = "async arrow function syntax";
+
+print(BUGNUMBER + ": " + summary);
+
+if (typeof Reflect !== "undefined" && Reflect.parse) {
+ // Parameters.
+ Reflect.parse("async () => 1");
+ Reflect.parse("async a => 1");
+ Reflect.parse("async (a) => 1");
+ Reflect.parse("async async => 1");
+ Reflect.parse("async (async) => 1");
+ Reflect.parse("async ([a]) => 1");
+ Reflect.parse("async ([a, b]) => 1");
+ Reflect.parse("async ({a}) => 1");
+ Reflect.parse("async ({a, b}) => 1");
+
+ assertThrows(() => Reflect.parse("async await => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async (await) => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async ([await]) => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async ({await}) => 1"), SyntaxError);
+
+ assertThrows(() => Reflect.parse("async (a=await) => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async ([a=await]) => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async ({a=await}) => 1"), SyntaxError);
+
+ assertThrows(() => Reflect.parse("async (a=await 1) => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async ([a=await 1]) => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async ({a=await 1}) => 1"), SyntaxError);
+
+ assertThrows(() => Reflect.parse("async [a] => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async [a, b] => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async {a} => 1"), SyntaxError);
+ assertThrows(() => Reflect.parse("async {a: b} => 1"), SyntaxError);
+
+ // Expression body.
+ Reflect.parse("async a => a == b");
+
+ // Expression body with nested async function.
+ Reflect.parse("async a => async");
+ Reflect.parse("async a => async b => c");
+ Reflect.parse("async a => async function() {}");
+ Reflect.parse("async a => async function b() {}");
+
+ assertThrows(() => Reflect.parse("async a => async b"), SyntaxError);
+ assertThrows(() => Reflect.parse("async a => async function"), SyntaxError);
+ assertThrows(() => Reflect.parse("async a => async function()"), SyntaxError);
+
+ // Expression body with `await`.
+ Reflect.parse("async a => await 1");
+ Reflect.parse("async a => await await 1");
+ Reflect.parse("async a => await await await 1");
+
+ assertThrows(() => Reflect.parse("async a => await"), SyntaxError);
+ assertThrows(() => Reflect.parse("async a => await await"), SyntaxError);
+
+ // `await` is Unary Expression and it cannot have `async` function as an
+ // operand.
+ assertThrows(() => Reflect.parse("async a => await async X => Y"), SyntaxError);
+ Reflect.parse("async a => await (async X => Y)");
+ // But it can have `async` identifier as an operand.
+ Reflect.parse("async async => await async");
+
+ // Block body.
+ Reflect.parse("async X => {yield}");
+
+ // `yield` handling.
+ Reflect.parse("async X => yield");
+ Reflect.parse("async yield => X");
+ Reflect.parse("async yield => yield");
+ Reflect.parse("async X => {yield}");
+
+ Reflect.parse("async X => {yield}");
+ Reflect.parse("async yield => {X}");
+ Reflect.parse("async yield => {yield}");
+ Reflect.parse("function* g() { async X => yield }");
+
+ assertThrows(() => Reflect.parse("'use strict'; async yield => X"), SyntaxError);
+ assertThrows(() => Reflect.parse("'use strict'; async (yield) => X"), SyntaxError);
+ assertThrows(() => Reflect.parse("'use strict'; async X => yield"), SyntaxError);
+ assertThrows(() => Reflect.parse("'use strict'; async X => {yield}"), SyntaxError);
+
+ assertThrows(() => Reflect.parse("function* g() { async yield => X }"));
+ assertThrows(() => Reflect.parse("function* g() { async (yield) => X }"));
+ assertThrows(() => Reflect.parse("function* g() { async ([yield]) => X }"));
+ assertThrows(() => Reflect.parse("function* g() { async ({yield}) => X }"));
+
+ // Not async functions.
+ Reflect.parse("async ()");
+ Reflect.parse("async (a)");
+ Reflect.parse("async (async)");
+ Reflect.parse("async ([a])");
+ Reflect.parse("async ([a, b])");
+ Reflect.parse("async ({a})");
+ Reflect.parse("async ({a, b})");
+
+ // Async arrow function is assignment expression.
+ Reflect.parse("a ? async () => {1} : b");
+ Reflect.parse("a ? b : async () => {1}");
+ assertThrows(() => Reflect.parse("async () => {1} ? a : b"), SyntaxError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);