From 021ed85d970e186ae18b18e6c690f396d1e7af74 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Thu, 10 Mar 2016 19:35:14 -0500 Subject: [PATCH] Add syntax tests for declaration restrictions Assert that declarations are not permitted in positions reserved for statements only. --- test/language/statements/do-while/decl-cls.js | 10 ++++++++ .../statements/do-while/decl-const.js | 10 ++++++++ test/language/statements/do-while/decl-fun.js | 10 ++++++++ test/language/statements/do-while/decl-gen.js | 10 ++++++++ test/language/statements/do-while/decl-let.js | 10 ++++++++ test/language/statements/for-in/decl-cls.js | 10 ++++++++ test/language/statements/for-in/decl-const.js | 10 ++++++++ test/language/statements/for-in/decl-fun.js | 10 ++++++++ test/language/statements/for-in/decl-gen.js | 10 ++++++++ test/language/statements/for-in/decl-let.js | 10 ++++++++ test/language/statements/for-of/decl-cls.js | 10 ++++++++ test/language/statements/for-of/decl-const.js | 10 ++++++++ test/language/statements/for-of/decl-fun.js | 10 ++++++++ test/language/statements/for-of/decl-gen.js | 10 ++++++++ test/language/statements/for-of/decl-let.js | 10 ++++++++ test/language/statements/for/decl-cls.js | 10 ++++++++ test/language/statements/for/decl-const.js | 10 ++++++++ test/language/statements/for/decl-fun.js | 10 ++++++++ test/language/statements/for/decl-gen.js | 10 ++++++++ test/language/statements/for/decl-let.js | 10 ++++++++ .../language/statements/if/if-cls-else-cls.js | 10 ++++++++ .../statements/if/if-cls-else-stmt.js | 10 ++++++++ test/language/statements/if/if-cls-no-else.js | 10 ++++++++ .../statements/if/if-const-else-const.js | 10 ++++++++ .../statements/if/if-const-else-stmt.js | 10 ++++++++ .../statements/if/if-const-no-else.js | 10 ++++++++ .../statements/if/if-fun-else-fun-strict.js | 21 ++++++++++++++++ .../statements/if/if-fun-else-stmt-strict.js | 21 ++++++++++++++++ .../statements/if/if-fun-no-else-strict.js | 21 ++++++++++++++++ .../language/statements/if/if-gen-else-gen.js | 10 ++++++++ .../statements/if/if-gen-else-stmt.js | 10 ++++++++ test/language/statements/if/if-gen-no-else.js | 10 ++++++++ .../language/statements/if/if-let-else-let.js | 10 ++++++++ .../statements/if/if-let-else-stmt.js | 10 ++++++++ test/language/statements/if/if-let-no-else.js | 10 ++++++++ .../statements/if/if-stmt-else-cls.js | 10 ++++++++ .../statements/if/if-stmt-else-const.js | 10 ++++++++ .../statements/if/if-stmt-else-fun-strict.js | 25 +++++++++++++++++++ .../statements/if/if-stmt-else-gen.js | 10 ++++++++ .../statements/if/if-stmt-else-let.js | 10 ++++++++ test/language/statements/labeled/decl-cls.js | 10 ++++++++ .../language/statements/labeled/decl-const.js | 10 ++++++++ ...claration-strict.js => decl-fun-strict.js} | 5 ++-- test/language/statements/labeled/decl-gen.js | 10 ++++++++ test/language/statements/labeled/decl-let.js | 10 ++++++++ test/language/statements/while/decl-cls.js | 10 ++++++++ test/language/statements/while/decl-const.js | 10 ++++++++ test/language/statements/while/decl-fun.js | 10 ++++++++ test/language/statements/while/decl-gen.js | 10 ++++++++ test/language/statements/while/decl-let.js | 10 ++++++++ test/language/statements/with/decl-cls.js | 11 ++++++++ test/language/statements/with/decl-const.js | 11 ++++++++ test/language/statements/with/decl-fun.js | 11 ++++++++ test/language/statements/with/decl-gen.js | 11 ++++++++ test/language/statements/with/decl-let.js | 11 ++++++++ 55 files changed, 596 insertions(+), 2 deletions(-) create mode 100644 test/language/statements/do-while/decl-cls.js create mode 100644 test/language/statements/do-while/decl-const.js create mode 100644 test/language/statements/do-while/decl-fun.js create mode 100644 test/language/statements/do-while/decl-gen.js create mode 100644 test/language/statements/do-while/decl-let.js create mode 100644 test/language/statements/for-in/decl-cls.js create mode 100644 test/language/statements/for-in/decl-const.js create mode 100644 test/language/statements/for-in/decl-fun.js create mode 100644 test/language/statements/for-in/decl-gen.js create mode 100644 test/language/statements/for-in/decl-let.js create mode 100644 test/language/statements/for-of/decl-cls.js create mode 100644 test/language/statements/for-of/decl-const.js create mode 100644 test/language/statements/for-of/decl-fun.js create mode 100644 test/language/statements/for-of/decl-gen.js create mode 100644 test/language/statements/for-of/decl-let.js create mode 100644 test/language/statements/for/decl-cls.js create mode 100644 test/language/statements/for/decl-const.js create mode 100644 test/language/statements/for/decl-fun.js create mode 100644 test/language/statements/for/decl-gen.js create mode 100644 test/language/statements/for/decl-let.js create mode 100644 test/language/statements/if/if-cls-else-cls.js create mode 100644 test/language/statements/if/if-cls-else-stmt.js create mode 100644 test/language/statements/if/if-cls-no-else.js create mode 100644 test/language/statements/if/if-const-else-const.js create mode 100644 test/language/statements/if/if-const-else-stmt.js create mode 100644 test/language/statements/if/if-const-no-else.js create mode 100644 test/language/statements/if/if-fun-else-fun-strict.js create mode 100644 test/language/statements/if/if-fun-else-stmt-strict.js create mode 100644 test/language/statements/if/if-fun-no-else-strict.js create mode 100644 test/language/statements/if/if-gen-else-gen.js create mode 100644 test/language/statements/if/if-gen-else-stmt.js create mode 100644 test/language/statements/if/if-gen-no-else.js create mode 100644 test/language/statements/if/if-let-else-let.js create mode 100644 test/language/statements/if/if-let-else-stmt.js create mode 100644 test/language/statements/if/if-let-no-else.js create mode 100644 test/language/statements/if/if-stmt-else-cls.js create mode 100644 test/language/statements/if/if-stmt-else-const.js create mode 100644 test/language/statements/if/if-stmt-else-fun-strict.js create mode 100644 test/language/statements/if/if-stmt-else-gen.js create mode 100644 test/language/statements/if/if-stmt-else-let.js create mode 100644 test/language/statements/labeled/decl-cls.js create mode 100644 test/language/statements/labeled/decl-const.js rename test/language/statements/labeled/{labelled-function-declaration-strict.js => decl-fun-strict.js} (88%) create mode 100644 test/language/statements/labeled/decl-gen.js create mode 100644 test/language/statements/labeled/decl-let.js create mode 100644 test/language/statements/while/decl-cls.js create mode 100644 test/language/statements/while/decl-const.js create mode 100644 test/language/statements/while/decl-fun.js create mode 100644 test/language/statements/while/decl-gen.js create mode 100644 test/language/statements/while/decl-let.js create mode 100644 test/language/statements/with/decl-cls.js create mode 100644 test/language/statements/with/decl-const.js create mode 100644 test/language/statements/with/decl-fun.js create mode 100644 test/language/statements/with/decl-gen.js create mode 100644 test/language/statements/with/decl-let.js diff --git a/test/language/statements/do-while/decl-cls.js b/test/language/statements/do-while/decl-cls.js new file mode 100644 index 0000000000..b88a399b8b --- /dev/null +++ b/test/language/statements/do-while/decl-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-do-while-statement +es6id: 13.7.2 +negative: SyntaxError +---*/ + +do class C {} while (false) diff --git a/test/language/statements/do-while/decl-const.js b/test/language/statements/do-while/decl-const.js new file mode 100644 index 0000000000..6e8a23a70f --- /dev/null +++ b/test/language/statements/do-while/decl-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-do-while-statement +es6id: 13.7.2 +negative: SyntaxError +---*/ + +do const x = null; while (false) diff --git a/test/language/statements/do-while/decl-fun.js b/test/language/statements/do-while/decl-fun.js new file mode 100644 index 0000000000..ff94a75480 --- /dev/null +++ b/test/language/statements/do-while/decl-fun.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-do-while-statement +es6id: 13.7.2 +negative: SyntaxError +---*/ + +do function f() {} while (false) diff --git a/test/language/statements/do-while/decl-gen.js b/test/language/statements/do-while/decl-gen.js new file mode 100644 index 0000000000..2e47fcc5fd --- /dev/null +++ b/test/language/statements/do-while/decl-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-do-while-statement +es6id: 13.7.2 +negative: SyntaxError +---*/ + +do function* g() {} while (false) diff --git a/test/language/statements/do-while/decl-let.js b/test/language/statements/do-while/decl-let.js new file mode 100644 index 0000000000..42c320ea45 --- /dev/null +++ b/test/language/statements/do-while/decl-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-do-while-statement +es6id: 13.7.2 +negative: SyntaxError +---*/ + +do let x; while (false) diff --git a/test/language/statements/for-in/decl-cls.js b/test/language/statements/for-in/decl-cls.js new file mode 100644 index 0000000000..85ff5e16a3 --- /dev/null +++ b/test/language/statements/for-in/decl-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x in {}) class C {} diff --git a/test/language/statements/for-in/decl-const.js b/test/language/statements/for-in/decl-const.js new file mode 100644 index 0000000000..3a55cd477d --- /dev/null +++ b/test/language/statements/for-in/decl-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x in {}) const y = null; diff --git a/test/language/statements/for-in/decl-fun.js b/test/language/statements/for-in/decl-fun.js new file mode 100644 index 0000000000..29509bc413 --- /dev/null +++ b/test/language/statements/for-in/decl-fun.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Function declaration not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x in {}) function f() {} diff --git a/test/language/statements/for-in/decl-gen.js b/test/language/statements/for-in/decl-gen.js new file mode 100644 index 0000000000..4d263ec376 --- /dev/null +++ b/test/language/statements/for-in/decl-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x in {}) function* g() {} diff --git a/test/language/statements/for-in/decl-let.js b/test/language/statements/for-in/decl-let.js new file mode 100644 index 0000000000..2cf556476d --- /dev/null +++ b/test/language/statements/for-in/decl-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x in {}) let y; diff --git a/test/language/statements/for-of/decl-cls.js b/test/language/statements/for-of/decl-cls.js new file mode 100644 index 0000000000..d33b4eb58e --- /dev/null +++ b/test/language/statements/for-of/decl-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x of []) class C {} diff --git a/test/language/statements/for-of/decl-const.js b/test/language/statements/for-of/decl-const.js new file mode 100644 index 0000000000..69d193185b --- /dev/null +++ b/test/language/statements/for-of/decl-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x of []) const y = null; diff --git a/test/language/statements/for-of/decl-fun.js b/test/language/statements/for-of/decl-fun.js new file mode 100644 index 0000000000..8001c192e9 --- /dev/null +++ b/test/language/statements/for-of/decl-fun.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Function declaration not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x of []) function f() {} diff --git a/test/language/statements/for-of/decl-gen.js b/test/language/statements/for-of/decl-gen.js new file mode 100644 index 0000000000..eb4b3aab1f --- /dev/null +++ b/test/language/statements/for-of/decl-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x of []) function* g() {} diff --git a/test/language/statements/for-of/decl-let.js b/test/language/statements/for-of/decl-let.js new file mode 100644 index 0000000000..93cd0725de --- /dev/null +++ b/test/language/statements/for-of/decl-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (var x of []) let y; diff --git a/test/language/statements/for/decl-cls.js b/test/language/statements/for/decl-cls.js new file mode 100644 index 0000000000..54a6ffbc50 --- /dev/null +++ b/test/language/statements/for/decl-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-for-statement +es6id: 13.7.4 +negative: SyntaxError +---*/ + +for ( ; false; ) class C {} diff --git a/test/language/statements/for/decl-const.js b/test/language/statements/for/decl-const.js new file mode 100644 index 0000000000..0c54e87741 --- /dev/null +++ b/test/language/statements/for/decl-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-for-statement +es6id: 13.7.4 +negative: SyntaxError +---*/ + +for ( ; false; ) const x = null; diff --git a/test/language/statements/for/decl-fun.js b/test/language/statements/for/decl-fun.js new file mode 100644 index 0000000000..ef3005a5c0 --- /dev/null +++ b/test/language/statements/for/decl-fun.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Function declaration not allowed in statement position +esid: sec-for-statement +es6id: 13.7.4 +negative: SyntaxError +---*/ + +for ( ; false; ) function f() {} diff --git a/test/language/statements/for/decl-gen.js b/test/language/statements/for/decl-gen.js new file mode 100644 index 0000000000..30a02fa163 --- /dev/null +++ b/test/language/statements/for/decl-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-for-statement +es6id: 13.7.4 +negative: SyntaxError +---*/ + +for ( ; false; ) function* g() {} diff --git a/test/language/statements/for/decl-let.js b/test/language/statements/for/decl-let.js new file mode 100644 index 0000000000..9b40c281d4 --- /dev/null +++ b/test/language/statements/for/decl-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-for-statement +es6id: 13.7.4 +negative: SyntaxError +---*/ + +for ( ; false; ) let x; diff --git a/test/language/statements/if/if-cls-else-cls.js b/test/language/statements/if/if-cls-else-cls.js new file mode 100644 index 0000000000..16e6728367 --- /dev/null +++ b/test/language/statements/if/if-cls-else-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) class C {} else class D {} diff --git a/test/language/statements/if/if-cls-else-stmt.js b/test/language/statements/if/if-cls-else-stmt.js new file mode 100644 index 0000000000..1c5fdca986 --- /dev/null +++ b/test/language/statements/if/if-cls-else-stmt.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) class C {} else ; diff --git a/test/language/statements/if/if-cls-no-else.js b/test/language/statements/if/if-cls-no-else.js new file mode 100644 index 0000000000..49956bf38c --- /dev/null +++ b/test/language/statements/if/if-cls-no-else.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) class C {} diff --git a/test/language/statements/if/if-const-else-const.js b/test/language/statements/if/if-const-else-const.js new file mode 100644 index 0000000000..fba8cdbadf --- /dev/null +++ b/test/language/statements/if/if-const-else-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) const x = null; else const y = null; diff --git a/test/language/statements/if/if-const-else-stmt.js b/test/language/statements/if/if-const-else-stmt.js new file mode 100644 index 0000000000..e051c1726c --- /dev/null +++ b/test/language/statements/if/if-const-else-stmt.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) const x = null; else ; diff --git a/test/language/statements/if/if-const-no-else.js b/test/language/statements/if/if-const-no-else.js new file mode 100644 index 0000000000..317751f4e4 --- /dev/null +++ b/test/language/statements/if/if-const-no-else.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) const x = null; diff --git a/test/language/statements/if/if-fun-else-fun-strict.js b/test/language/statements/if/if-fun-else-fun-strict.js new file mode 100644 index 0000000000..f6f5837874 --- /dev/null +++ b/test/language/statements/if/if-fun-else-fun-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: SyntaxError +info: > + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +if (true) function f() {} else function _f() {} diff --git a/test/language/statements/if/if-fun-else-stmt-strict.js b/test/language/statements/if/if-fun-else-stmt-strict.js new file mode 100644 index 0000000000..fcb8da8deb --- /dev/null +++ b/test/language/statements/if/if-fun-else-stmt-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: SyntaxError +info: > + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +if (true) function f() {} else ; diff --git a/test/language/statements/if/if-fun-no-else-strict.js b/test/language/statements/if/if-fun-no-else-strict.js new file mode 100644 index 0000000000..7e1199e363 --- /dev/null +++ b/test/language/statements/if/if-fun-no-else-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement without an else clause in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: SyntaxError +info: > + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + The above rules are only applied when parsing code that is not strict mode code. +---*/ + +if (true) function f() {} diff --git a/test/language/statements/if/if-gen-else-gen.js b/test/language/statements/if/if-gen-else-gen.js new file mode 100644 index 0000000000..438b1e2cb6 --- /dev/null +++ b/test/language/statements/if/if-gen-else-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) function* g() { } else function* _g() {} diff --git a/test/language/statements/if/if-gen-else-stmt.js b/test/language/statements/if/if-gen-else-stmt.js new file mode 100644 index 0000000000..a39b393374 --- /dev/null +++ b/test/language/statements/if/if-gen-else-stmt.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) function* g() { } else ; diff --git a/test/language/statements/if/if-gen-no-else.js b/test/language/statements/if/if-gen-no-else.js new file mode 100644 index 0000000000..5a90a93a5a --- /dev/null +++ b/test/language/statements/if/if-gen-no-else.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) function* g() { } diff --git a/test/language/statements/if/if-let-else-let.js b/test/language/statements/if/if-let-else-let.js new file mode 100644 index 0000000000..4991327704 --- /dev/null +++ b/test/language/statements/if/if-let-else-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) let x; else let y; diff --git a/test/language/statements/if/if-let-else-stmt.js b/test/language/statements/if/if-let-else-stmt.js new file mode 100644 index 0000000000..065476cb9b --- /dev/null +++ b/test/language/statements/if/if-let-else-stmt.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) let x; else ; diff --git a/test/language/statements/if/if-let-no-else.js b/test/language/statements/if/if-let-no-else.js new file mode 100644 index 0000000000..c24f675ea2 --- /dev/null +++ b/test/language/statements/if/if-let-no-else.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (true) let x; diff --git a/test/language/statements/if/if-stmt-else-cls.js b/test/language/statements/if/if-stmt-else-cls.js new file mode 100644 index 0000000000..2d05e58d8a --- /dev/null +++ b/test/language/statements/if/if-stmt-else-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (false) ; else class C {} diff --git a/test/language/statements/if/if-stmt-else-const.js b/test/language/statements/if/if-stmt-else-const.js new file mode 100644 index 0000000000..e8746d34db --- /dev/null +++ b/test/language/statements/if/if-stmt-else-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (false) ; else const x = null; diff --git a/test/language/statements/if/if-stmt-else-fun-strict.js b/test/language/statements/if/if-stmt-else-fun-strict.js new file mode 100644 index 0000000000..80326edf3e --- /dev/null +++ b/test/language/statements/if/if-stmt-else-fun-strict.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AnnexB extension not honored in strict mode (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-if-statement +es6id: 13.6 +flags: [onlyStrict] +negative: SyntaxError +info: > + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + 1. 1. Let strict be IsStrict of script + 2. If strict is *false*, then + [...] +---*/ + +if (false) ; else function f() {} diff --git a/test/language/statements/if/if-stmt-else-gen.js b/test/language/statements/if/if-stmt-else-gen.js new file mode 100644 index 0000000000..d5a158e294 --- /dev/null +++ b/test/language/statements/if/if-stmt-else-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (false) ; else function* g() { } diff --git a/test/language/statements/if/if-stmt-else-let.js b/test/language/statements/if/if-stmt-else-let.js new file mode 100644 index 0000000000..28cd5a74ac --- /dev/null +++ b/test/language/statements/if/if-stmt-else-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-if-statement +es6id: 13.6 +negative: SyntaxError +---*/ + +if (false) ; else let x; diff --git a/test/language/statements/labeled/decl-cls.js b/test/language/statements/labeled/decl-cls.js new file mode 100644 index 0000000000..5b94766564 --- /dev/null +++ b/test/language/statements/labeled/decl-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: SyntaxError +---*/ + +label: class C {} diff --git a/test/language/statements/labeled/decl-const.js b/test/language/statements/labeled/decl-const.js new file mode 100644 index 0000000000..0cbc8f8693 --- /dev/null +++ b/test/language/statements/labeled/decl-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: SyntaxError +---*/ + +label: const x = null; diff --git a/test/language/statements/labeled/labelled-function-declaration-strict.js b/test/language/statements/labeled/decl-fun-strict.js similarity index 88% rename from test/language/statements/labeled/labelled-function-declaration-strict.js rename to test/language/statements/labeled/decl-fun-strict.js index 9f6fa35e41..edbf6a3d0d 100644 --- a/test/language/statements/labeled/labelled-function-declaration-strict.js +++ b/test/language/statements/labeled/decl-fun-strict.js @@ -1,12 +1,13 @@ // Copyright (C) 2011 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 13.1 +esid: sec-labelled-statements +es6id: 13.13 description: > function declarations in statement position in strict mode: label: Statement flags: [onlyStrict] negative: SyntaxError ---*/ -label: function g() {} +label: function g() {} diff --git a/test/language/statements/labeled/decl-gen.js b/test/language/statements/labeled/decl-gen.js new file mode 100644 index 0000000000..7ba25d863e --- /dev/null +++ b/test/language/statements/labeled/decl-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: SyntaxError +---*/ + +label: function* g() {} diff --git a/test/language/statements/labeled/decl-let.js b/test/language/statements/labeled/decl-let.js new file mode 100644 index 0000000000..8d5d9e5d5d --- /dev/null +++ b/test/language/statements/labeled/decl-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: SyntaxError +---*/ + +label: let x; diff --git a/test/language/statements/while/decl-cls.js b/test/language/statements/while/decl-cls.js new file mode 100644 index 0000000000..f2c30d1e63 --- /dev/null +++ b/test/language/statements/while/decl-cls.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-while-statement +es6id: 13.7.3 +negative: SyntaxError +---*/ + +while (false) class C {} diff --git a/test/language/statements/while/decl-const.js b/test/language/statements/while/decl-const.js new file mode 100644 index 0000000000..93b313f3ce --- /dev/null +++ b/test/language/statements/while/decl-const.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-while-statement +es6id: 13.7.3 +negative: SyntaxError +---*/ + +while (false) const x = null; diff --git a/test/language/statements/while/decl-fun.js b/test/language/statements/while/decl-fun.js new file mode 100644 index 0000000000..e76d8c893f --- /dev/null +++ b/test/language/statements/while/decl-fun.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Function declaration not allowed in statement position +esid: sec-while-statement +es6id: 13.7.3 +negative: SyntaxError +---*/ + +while (false) function f() {} diff --git a/test/language/statements/while/decl-gen.js b/test/language/statements/while/decl-gen.js new file mode 100644 index 0000000000..62973f4581 --- /dev/null +++ b/test/language/statements/while/decl-gen.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-while-statement +es6id: 13.7.3 +negative: SyntaxError +---*/ + +while (false) function* g() {} diff --git a/test/language/statements/while/decl-let.js b/test/language/statements/while/decl-let.js new file mode 100644 index 0000000000..920673f56c --- /dev/null +++ b/test/language/statements/while/decl-let.js @@ -0,0 +1,10 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-while-statement +es6id: 13.7.3 +negative: SyntaxError +---*/ + +while (false) let x; diff --git a/test/language/statements/with/decl-cls.js b/test/language/statements/with/decl-cls.js new file mode 100644 index 0000000000..18f1f9ab5f --- /dev/null +++ b/test/language/statements/with/decl-cls.js @@ -0,0 +1,11 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-with-statement +es6id: 13.11 +flags: [noStrict] +negative: SyntaxError +---*/ + +with ({}) class C {} diff --git a/test/language/statements/with/decl-const.js b/test/language/statements/with/decl-const.js new file mode 100644 index 0000000000..d5e5b8aeb1 --- /dev/null +++ b/test/language/statements/with/decl-const.js @@ -0,0 +1,11 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-with-statement +es6id: 13.11 +flags: [noStrict] +negative: SyntaxError +---*/ + +with ({}) const x = null; diff --git a/test/language/statements/with/decl-fun.js b/test/language/statements/with/decl-fun.js new file mode 100644 index 0000000000..3bed84ea2d --- /dev/null +++ b/test/language/statements/with/decl-fun.js @@ -0,0 +1,11 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Function declaration not allowed in statement position +esid: sec-with-statement +es6id: 13.11 +flags: [noStrict] +negative: SyntaxError +---*/ + +with ({}) function f() {} diff --git a/test/language/statements/with/decl-gen.js b/test/language/statements/with/decl-gen.js new file mode 100644 index 0000000000..0d0c2451e2 --- /dev/null +++ b/test/language/statements/with/decl-gen.js @@ -0,0 +1,11 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-with-statement +es6id: 13.11 +flags: [noStrict] +negative: SyntaxError +---*/ + +with ({}) function* g() {} diff --git a/test/language/statements/with/decl-let.js b/test/language/statements/with/decl-let.js new file mode 100644 index 0000000000..9293c0aa56 --- /dev/null +++ b/test/language/statements/with/decl-let.js @@ -0,0 +1,11 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-with-statement +es6id: 13.11 +flags: [noStrict] +negative: SyntaxError +---*/ + +with ({}) let x;