Debian Codegraph @

js/src/tests/non262/async-functions/EarlyErrors.js

raw
1 var BUGNUMBER = 1185106;
2 var summary = "EarlyErrors for async function";
3
4 print(BUGNUMBER + ": " + summary);
5
6 function assertThrowsSE(code) {
7 assertThrowsInstanceOf(() => Reflect.parse(code), SyntaxError);
8 }
9
10 if (typeof Reflect !== "undefined" && Reflect.parse) {
11 // If FormalParameters Contains AwaitExpression is true.
12 assertThrowsSE("async function a(k = await 3) {}");
13 assertThrowsSE("(async function(k = await 3) {})");
14 assertThrowsSE("(async function a(k = await 3) {})");
15
16 // If BindingIdentifier is `eval` or `arguments`.
17 assertThrowsSE("'use strict'; async function eval() {}");
18 assertThrowsSE("'use strict'; (async function eval() {})");
19
20 assertThrowsSE("'use strict'; async function arguments() {}");
21 assertThrowsSE("'use strict'; (async function arguments() {})");
22
23 // If any element of the BoundNames of FormalParameters also occurs in the
24 // LexicallyDeclaredNames of AsyncFunctionBody.
25 assertThrowsSE("async function a(x) { let x; }");
26 assertThrowsSE("(async function(x) { let x; })");
27 assertThrowsSE("(async function a(x) { let x; })");
28
29 // If FormalParameters contains SuperProperty is true.
30 assertThrowsSE("async function a(k = super.prop) { }");
31 assertThrowsSE("(async function(k = super.prop) {})");
32 assertThrowsSE("(async function a(k = super.prop) {})");
33
34 // If AsyncFunctionBody contains SuperProperty is true.
35 assertThrowsSE("async function a() { super.prop(); }");
36 assertThrowsSE("(async function() { super.prop(); })");
37 assertThrowsSE("(async function a() { super.prop(); })");
38
39 // If FormalParameters contains SuperCall is true.
40 assertThrowsSE("async function a(k = super()) {}");
41 assertThrowsSE("(async function(k = super()) {})");
42 assertThrowsSE("(async function a(k = super()) {})");
43
44 // If AsyncFunctionBody contains SuperCall is true.
45 assertThrowsSE("async function a() { super(); }");
46 assertThrowsSE("(async function() { super(); })");
47 assertThrowsSE("(async function a() { super(); })");
48 }
49
50 if (typeof reportCompare === "function")
51 reportCompare(true, true);