1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var AsyncGenerator = async function*(){}.constructor;
function assertSyntaxError(code) {
var functionCode = `async function* f() { ${code} }`;
assertThrowsInstanceOf(() => AsyncGenerator(code), SyntaxError, "AsyncGenerator:" + code);
assertThrowsInstanceOf(() => eval(functionCode), SyntaxError, "eval:" + functionCode);
var ieval = eval;
assertThrowsInstanceOf(() => ieval(functionCode), SyntaxError, "indirect eval:" + functionCode);
}
assertSyntaxError(`for await (;;) ;`);
for (var decl of ["", "var", "let", "const"]) {
for (var head of ["a", "a = 0", "a, b", "[a]", "[a] = 0", "{a}", "{a} = 0"]) {
// Ends with C-style for loop syntax.
assertSyntaxError(`for await (${decl} ${head} ;;) ;`);
// Ends with for-in loop syntax.
assertSyntaxError(`for await (${decl} ${head} in null) ;`);
}
}
if (typeof reportCompare === "function")
reportCompare(0, 0);
|