From 75d153d2803c5e8c370649881ce7eaa0cb75f60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Tue, 2 May 2017 12:09:27 -0700 Subject: [PATCH] Add tests to ensure async-functions/generators are not accepted in statement position --- .../statements/do-while/decl-async-fun.js | 18 ++++++++++++++++++ .../statements/do-while/decl-async-gen.js | 18 ++++++++++++++++++ .../statements/for-in/decl-async-fun.js | 18 ++++++++++++++++++ .../statements/for-in/decl-async-gen.js | 18 ++++++++++++++++++ .../statements/for-of/decl-async-fun.js | 18 ++++++++++++++++++ .../statements/for-of/decl-async-gen.js | 18 ++++++++++++++++++ .../language/statements/for/decl-async-fun.js | 18 ++++++++++++++++++ .../language/statements/for/decl-async-gen.js | 18 ++++++++++++++++++ .../if/if-async-fun-else-async-fun.js | 18 ++++++++++++++++++ .../statements/if/if-async-fun-else-stmt.js | 18 ++++++++++++++++++ .../statements/if/if-async-fun-no-else.js | 18 ++++++++++++++++++ .../if/if-async-gen-else-async-gen.js | 18 ++++++++++++++++++ .../statements/if/if-async-gen-else-stmt.js | 18 ++++++++++++++++++ .../statements/if/if-async-gen-no-else.js | 18 ++++++++++++++++++ .../statements/if/if-stmt-else-async-fun.js | 18 ++++++++++++++++++ .../statements/if/if-stmt-else-async-gen.js | 18 ++++++++++++++++++ .../statements/labeled/decl-async-function.js | 18 ++++++++++++++++++ .../labeled/decl-async-generator.js | 18 ++++++++++++++++++ .../statements/while/decl-async-fun.js | 18 ++++++++++++++++++ .../statements/while/decl-async-gen.js | 18 ++++++++++++++++++ .../statements/with/decl-async-fun.js | 19 +++++++++++++++++++ .../statements/with/decl-async-gen.js | 19 +++++++++++++++++++ 22 files changed, 398 insertions(+) create mode 100644 test/language/statements/do-while/decl-async-fun.js create mode 100644 test/language/statements/do-while/decl-async-gen.js create mode 100644 test/language/statements/for-in/decl-async-fun.js create mode 100644 test/language/statements/for-in/decl-async-gen.js create mode 100644 test/language/statements/for-of/decl-async-fun.js create mode 100644 test/language/statements/for-of/decl-async-gen.js create mode 100644 test/language/statements/for/decl-async-fun.js create mode 100644 test/language/statements/for/decl-async-gen.js create mode 100644 test/language/statements/if/if-async-fun-else-async-fun.js create mode 100644 test/language/statements/if/if-async-fun-else-stmt.js create mode 100644 test/language/statements/if/if-async-fun-no-else.js create mode 100644 test/language/statements/if/if-async-gen-else-async-gen.js create mode 100644 test/language/statements/if/if-async-gen-else-stmt.js create mode 100644 test/language/statements/if/if-async-gen-no-else.js create mode 100644 test/language/statements/if/if-stmt-else-async-fun.js create mode 100644 test/language/statements/if/if-stmt-else-async-gen.js create mode 100644 test/language/statements/labeled/decl-async-function.js create mode 100644 test/language/statements/labeled/decl-async-generator.js create mode 100644 test/language/statements/while/decl-async-fun.js create mode 100644 test/language/statements/while/decl-async-gen.js create mode 100644 test/language/statements/with/decl-async-fun.js create mode 100644 test/language/statements/with/decl-async-gen.js diff --git a/test/language/statements/do-while/decl-async-fun.js b/test/language/statements/do-while/decl-async-fun.js new file mode 100644 index 0000000000..adcd9046b6 --- /dev/null +++ b/test/language/statements/do-while/decl-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-do-while-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +do async function f() {} while (false) diff --git a/test/language/statements/do-while/decl-async-gen.js b/test/language/statements/do-while/decl-async-gen.js new file mode 100644 index 0000000000..668bbe16cf --- /dev/null +++ b/test/language/statements/do-while/decl-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-do-while-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +do async function* g() {} while (false) diff --git a/test/language/statements/for-in/decl-async-fun.js b/test/language/statements/for-in/decl-async-fun.js new file mode 100644 index 0000000000..53dfffed1f --- /dev/null +++ b/test/language/statements/for-in/decl-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-in-and-for-of-statements +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +for (var x in {}) async function f() {} diff --git a/test/language/statements/for-in/decl-async-gen.js b/test/language/statements/for-in/decl-async-gen.js new file mode 100644 index 0000000000..30f85d929c --- /dev/null +++ b/test/language/statements/for-in/decl-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-in-and-for-of-statements +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +for (var x in {}) async function* g() {} diff --git a/test/language/statements/for-of/decl-async-fun.js b/test/language/statements/for-of/decl-async-fun.js new file mode 100644 index 0000000000..031c17da03 --- /dev/null +++ b/test/language/statements/for-of/decl-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-in-and-for-of-statements +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +for (var x of []) async function f() {} diff --git a/test/language/statements/for-of/decl-async-gen.js b/test/language/statements/for-of/decl-async-gen.js new file mode 100644 index 0000000000..282f161dcc --- /dev/null +++ b/test/language/statements/for-of/decl-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-in-and-for-of-statements +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +for (var x of []) async function* g() {} diff --git a/test/language/statements/for/decl-async-fun.js b/test/language/statements/for/decl-async-fun.js new file mode 100644 index 0000000000..c9421e52f4 --- /dev/null +++ b/test/language/statements/for/decl-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +for ( ; false; ) async function f() {} diff --git a/test/language/statements/for/decl-async-gen.js b/test/language/statements/for/decl-async-gen.js new file mode 100644 index 0000000000..61ef718d2a --- /dev/null +++ b/test/language/statements/for/decl-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +for ( ; false; ) async function* g() {} diff --git a/test/language/statements/if/if-async-fun-else-async-fun.js b/test/language/statements/if/if-async-fun-else-async-fun.js new file mode 100644 index 0000000000..2c146f775d --- /dev/null +++ b/test/language/statements/if/if-async-fun-else-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +if (true) async function f() { } else async function _f() {} diff --git a/test/language/statements/if/if-async-fun-else-stmt.js b/test/language/statements/if/if-async-fun-else-stmt.js new file mode 100644 index 0000000000..c686fb04cf --- /dev/null +++ b/test/language/statements/if/if-async-fun-else-stmt.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +if (true) async function f() { } else ; diff --git a/test/language/statements/if/if-async-fun-no-else.js b/test/language/statements/if/if-async-fun-no-else.js new file mode 100644 index 0000000000..0fdfc420f2 --- /dev/null +++ b/test/language/statements/if/if-async-fun-no-else.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +if (true) async function f() { } diff --git a/test/language/statements/if/if-async-gen-else-async-gen.js b/test/language/statements/if/if-async-gen-else-async-gen.js new file mode 100644 index 0000000000..a817fbebad --- /dev/null +++ b/test/language/statements/if/if-async-gen-else-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +if (true) async function* f() { } else async function* _f() {} diff --git a/test/language/statements/if/if-async-gen-else-stmt.js b/test/language/statements/if/if-async-gen-else-stmt.js new file mode 100644 index 0000000000..41d8645400 --- /dev/null +++ b/test/language/statements/if/if-async-gen-else-stmt.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +if (true) async function* f() { } else ; diff --git a/test/language/statements/if/if-async-gen-no-else.js b/test/language/statements/if/if-async-gen-no-else.js new file mode 100644 index 0000000000..8becde1f99 --- /dev/null +++ b/test/language/statements/if/if-async-gen-no-else.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +if (true) async function* f() { } diff --git a/test/language/statements/if/if-stmt-else-async-fun.js b/test/language/statements/if/if-stmt-else-async-fun.js new file mode 100644 index 0000000000..67834c307f --- /dev/null +++ b/test/language/statements/if/if-stmt-else-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +if (false) ; else async function f() { } diff --git a/test/language/statements/if/if-stmt-else-async-gen.js b/test/language/statements/if/if-stmt-else-async-gen.js new file mode 100644 index 0000000000..3a7c747825 --- /dev/null +++ b/test/language/statements/if/if-stmt-else-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +if (false) ; else async function* f() { } diff --git a/test/language/statements/labeled/decl-async-function.js b/test/language/statements/labeled/decl-async-function.js new file mode 100644 index 0000000000..b302af9315 --- /dev/null +++ b/test/language/statements/labeled/decl-async-function.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-labelled-statements +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +label: async function f() {} diff --git a/test/language/statements/labeled/decl-async-generator.js b/test/language/statements/labeled/decl-async-generator.js new file mode 100644 index 0000000000..0f2c2baccc --- /dev/null +++ b/test/language/statements/labeled/decl-async-generator.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-labelled-statements +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +label: async function* g() {} diff --git a/test/language/statements/while/decl-async-fun.js b/test/language/statements/while/decl-async-fun.js new file mode 100644 index 0000000000..76e14cb7b0 --- /dev/null +++ b/test/language/statements/while/decl-async-fun.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-while-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +---*/ + +while (false) async function f() {} diff --git a/test/language/statements/while/decl-async-gen.js b/test/language/statements/while/decl-async-gen.js new file mode 100644 index 0000000000..5cdacb1eea --- /dev/null +++ b/test/language/statements/while/decl-async-gen.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-while-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +---*/ + +while (false) async function* g() {} diff --git a/test/language/statements/with/decl-async-fun.js b/test/language/statements/with/decl-async-fun.js new file mode 100644 index 0000000000..77f69d1d9b --- /dev/null +++ b/test/language/statements/with/decl-async-fun.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-with-statement +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-functions] +flags: [noStrict] +---*/ + +with ({}) async function f() {} diff --git a/test/language/statements/with/decl-async-gen.js b/test/language/statements/with/decl-async-gen.js new file mode 100644 index 0000000000..98d2b2e12e --- /dev/null +++ b/test/language/statements/with/decl-async-gen.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-with-statement +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: early + type: SyntaxError +features: [async-iteration] +flags: [noStrict] +---*/ + +with ({}) async function* g() {}