summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/async-functions/async-property-name-error.js
blob: 926794e5d0f037273ced5afc7399ad7be9984a70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function assertSyntaxError(code) {
    assertThrowsInstanceOf(() => { Function(code); }, SyntaxError, "Function:" + code);
    assertThrowsInstanceOf(() => { eval(code); }, SyntaxError, "eval:" + code);
    var ieval = eval;
    assertThrowsInstanceOf(() => { ieval(code); }, SyntaxError, "indirect eval:" + code);
}

assertSyntaxError(`({async async: 0})`);
assertSyntaxError(`({async async})`);
assertSyntaxError(`({async async, })`);
assertSyntaxError(`({async async = 0} = {})`);

for (let decl of ["var", "let", "const"]) {
    assertSyntaxError(`${decl} {async async: a} = {}`);
    assertSyntaxError(`${decl} {async async} = {}`);
    assertSyntaxError(`${decl} {async async, } = {}`);
    assertSyntaxError(`${decl} {async async = 0} = {}`);
}

if (typeof reportCompare === "function")
    reportCompare(true, true);