diff --git a/test/language/statements/do-while/labeled-fn-stmt.js b/test/language/statements/do-while/labeled-fn-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..0469dc9b8fe5d7bc8997af19b876134c52bed578 --- /dev/null +++ b/test/language/statements/do-while/labeled-fn-stmt.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +do label1: label2: function f() {} while (false) diff --git a/test/language/statements/for-in/head-const-bound-names-dup.js b/test/language/statements/for-in/head-const-bound-names-dup.js new file mode 100644 index 0000000000000000000000000000000000000000..a0afd41eb162159211b172e846f947267a688c89 --- /dev/null +++ b/test/language/statements/for-in/head-const-bound-names-dup.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The head's declaration may not contain duplicate entries +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains any + duplicate entries. +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +---*/ + +for (const [x, x] in {}) {} diff --git a/test/language/statements/for-in/head-const-bound-names-in-stmt.js b/test/language/statements/for-in/head-const-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..3f8001633ec0f267040fed500fa64fc88092dfcf --- /dev/null +++ b/test/language/statements/for-in/head-const-bound-names-in-stmt.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may not re-declare variables declared in the head +negative: SyntaxError +info: | + It is a Syntax Error if any element of the BoundNames of ForDeclaration + also occurs in the VarDeclaredNames of Statement. +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +---*/ + +for (const x in {}) { + var x; +} diff --git a/test/language/statements/for-in/head-const-bound-names-let.js b/test/language/statements/for-in/head-const-bound-names-let.js new file mode 100644 index 0000000000000000000000000000000000000000..ddaea955aa589ee086ac4c25e1cbca26c80f569e --- /dev/null +++ b/test/language/statements/for-in/head-const-bound-names-let.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The declaration may not contain a binding for `let` +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains "let". +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +flags: [noStrict] +---*/ + +for (const let in {}) {} diff --git a/test/language/statements/for-in/head-let-bound-names-dup.js b/test/language/statements/for-in/head-let-bound-names-dup.js new file mode 100644 index 0000000000000000000000000000000000000000..8e395f5f93731a27bd364e60d1cf13beb3faed84 --- /dev/null +++ b/test/language/statements/for-in/head-let-bound-names-dup.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The head's declaration may not contain duplicate entries +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains any + duplicate entries. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +for (let [x, x] in {}) {} diff --git a/test/language/statements/for-in/head-let-bound-names-in-stmt.js b/test/language/statements/for-in/head-let-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..219a7fd2e2076d8cb3e161b6c0e2ec8e155698c5 --- /dev/null +++ b/test/language/statements/for-in/head-let-bound-names-in-stmt.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may not re-declare variables declared in the head +negative: SyntaxError +info: | + It is a Syntax Error if any element of the BoundNames of ForDeclaration + also occurs in the VarDeclaredNames of Statement. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +for (let x in {}) { + var x; +} diff --git a/test/language/statements/for-in/head-let-bound-names-let.js b/test/language/statements/for-in/head-let-bound-names-let.js new file mode 100644 index 0000000000000000000000000000000000000000..d70fbc5e9b32cd38d7a18c36f077c0386c9a3c00 --- /dev/null +++ b/test/language/statements/for-in/head-let-bound-names-let.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The declaration may not contain a binding for `let` +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains "let". +flags: [noStrict] +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +---*/ + +for (let let in {}) {} diff --git a/test/language/statements/for-in/head-lhs-cover-non-asnmt-trgt.js b/test/language/statements/for-in/head-lhs-cover-non-asnmt-trgt.js new file mode 100644 index 0000000000000000000000000000000000000000..ea340a318ae1b6c071bd9da4194d79b96f98c5cf --- /dev/null +++ b/test/language/statements/for-in/head-lhs-cover-non-asnmt-trgt.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Head's LeftHandSideExpression must be a simple assignment target +info: > + It is a Syntax Error if IsValidSimpleAssignmentTarget of + LeftHandSideExpression is false. + + It is a Syntax Error if the LeftHandSideExpression is + CoverParenthesizedExpressionAndArrowParameterList : ( Expression ) and + Expression derives a production that would produce a Syntax Error according + to these rules if that production is substituted for + LeftHandSideExpression. This rule is recursively applied. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for ((this) in {}) {} diff --git a/test/language/statements/for-in/head-lhs-cover.js b/test/language/statements/for-in/head-lhs-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..f72f6ba4c8e486939e148c3c58c4829f7cd3e5d0 --- /dev/null +++ b/test/language/statements/for-in/head-lhs-cover.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Head's AssignmentExpression may be CoverParenthesizedExpressionAndArrowParameterList +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; +var x; + +for ((x) in { attr: null }) { + assert.sameValue(x, 'attr'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/head-lhs-invalid-asnmt-ptrn-ary.js b/test/language/statements/for-in/head-lhs-invalid-asnmt-ptrn-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..460f9128e8991c69752381db0ecfd440379a4668 --- /dev/null +++ b/test/language/statements/for-in/head-lhs-invalid-asnmt-ptrn-ary.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invalid destructuring assignment pattern (array literal) +info: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for ([(x, y)] in {}) {} diff --git a/test/language/statements/for-in/head-lhs-invalid-asnmt-ptrn-obj.js b/test/language/statements/for-in/head-lhs-invalid-asnmt-ptrn-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..871ebfb4aacb3e0d98ab9712e52f080d1d5bb366 --- /dev/null +++ b/test/language/statements/for-in/head-lhs-invalid-asnmt-ptrn-obj.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invalid destructuring assignment pattern (object literal) +info: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for ({ m() {} } in {}) {} diff --git a/test/language/statements/for-in/head-lhs-member.js b/test/language/statements/for-in/head-lhs-member.js new file mode 100644 index 0000000000000000000000000000000000000000..c9268a4a03fb0b19d60cdb6dde9164459948859e --- /dev/null +++ b/test/language/statements/for-in/head-lhs-member.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Head's AssignmentExpression may be a MemberExpression +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; +var x = {}; + +for (x.y in { attr: null }) { + assert.sameValue(x.y, 'attr'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/head-lhs-non-asnmt-trgt.js b/test/language/statements/for-in/head-lhs-non-asnmt-trgt.js new file mode 100644 index 0000000000000000000000000000000000000000..55e906093db7ab26d47786fe5ec8caf671871930 --- /dev/null +++ b/test/language/statements/for-in/head-lhs-non-asnmt-trgt.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Head's LeftHandSideExpression must be a simple assignment target +info: > + It is a Syntax Error if IsValidSimpleAssignmentTarget of + LeftHandSideExpression is false. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (this in {}) {} diff --git a/test/language/statements/for-in/head-var-bound-names-dup.js b/test/language/statements/for-in/head-var-bound-names-dup.js new file mode 100644 index 0000000000000000000000000000000000000000..51720244183c40eef3122b915845ad0a806b521c --- /dev/null +++ b/test/language/statements/for-in/head-var-bound-names-dup.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The head's declaration may contain duplicate entries +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; + +for (var [x, x] in { ab: null }) { + assert.sameValue(x, 'b'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/head-var-bound-names-in-stmt.js b/test/language/statements/for-in/head-var-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..58e318061974fe98179ed4bf503fff2a3064ed89 --- /dev/null +++ b/test/language/statements/for-in/head-var-bound-names-in-stmt.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may re-declare variables declared in the head +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; + +for (var x in { attr: null }) { + var x; + + assert.sameValue(x, 'attr'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/head-var-bound-names-let.js b/test/language/statements/for-in/head-var-bound-names-let.js new file mode 100644 index 0000000000000000000000000000000000000000..731541bfaba9168e5e9bd10ceea88c84d0e85d43 --- /dev/null +++ b/test/language/statements/for-in/head-var-bound-names-let.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The head's bound names may include "let" +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +flags: [noStrict] +---*/ + +var iterCount = 0; + +for (var let in { attr: null }) { + assert.sameValue(let, 'attr'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/labeled-fn-stmt-const.js b/test/language/statements/for-in/labeled-fn-stmt-const.js new file mode 100644 index 0000000000000000000000000000000000000000..9feb0161cc2b1908c3d74d4149cdf880ab340a1b --- /dev/null +++ b/test/language/statements/for-in/labeled-fn-stmt-const.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (const x in {}) label1: label2: function f() {} diff --git a/test/language/statements/for-in/labeled-fn-stmt-let.js b/test/language/statements/for-in/labeled-fn-stmt-let.js new file mode 100644 index 0000000000000000000000000000000000000000..6e2c24e0cfddf897b5e142b9d494e4ef139b3c8b --- /dev/null +++ b/test/language/statements/for-in/labeled-fn-stmt-let.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (let x in {}) label1: label2: function f() {} diff --git a/test/language/statements/for-in/labeled-fn-stmt-lhs.js b/test/language/statements/for-in/labeled-fn-stmt-lhs.js new file mode 100644 index 0000000000000000000000000000000000000000..bc5f6490cea31c364416c0fa139dd07c63ad8a70 --- /dev/null +++ b/test/language/statements/for-in/labeled-fn-stmt-lhs.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (x in {}) label1: label2: function f() {} diff --git a/test/language/statements/for-in/labeled-fn-stmt-var.js b/test/language/statements/for-in/labeled-fn-stmt-var.js new file mode 100644 index 0000000000000000000000000000000000000000..25a17fe36fa968e8a4fe49beaf08893322469fef --- /dev/null +++ b/test/language/statements/for-in/labeled-fn-stmt-var.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (var x in {}) label1: label2: function f() {} diff --git a/test/language/statements/for-of/head-const-bound-names-dup.js b/test/language/statements/for-of/head-const-bound-names-dup.js new file mode 100644 index 0000000000000000000000000000000000000000..0fbfeeb269779d9973c4d4f926416a259759b133 --- /dev/null +++ b/test/language/statements/for-of/head-const-bound-names-dup.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The head's declaration may not contain duplicate entries +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains any + duplicate entries. +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +---*/ + +for (const [x, x] of []) {} diff --git a/test/language/statements/for-of/head-const-bound-names-in-stmt.js b/test/language/statements/for-of/head-const-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..a9cafda4e3b6f479f0171153b6c3c31506353b5d --- /dev/null +++ b/test/language/statements/for-of/head-const-bound-names-in-stmt.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may not re-declare variables declared in the head +negative: SyntaxError +info: | + It is a Syntax Error if any element of the BoundNames of ForDeclaration + also occurs in the VarDeclaredNames of Statement. +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +---*/ + +for (const x of []) { + var x; +} diff --git a/test/language/statements/for-of/head-const-bound-names-let.js b/test/language/statements/for-of/head-const-bound-names-let.js new file mode 100644 index 0000000000000000000000000000000000000000..07b2cbfea9d18fd453517c28f2aca99c7a887499 --- /dev/null +++ b/test/language/statements/for-of/head-const-bound-names-let.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The declaration may not contain a binding for `let` +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains "let". +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +flags: [noStrict] +---*/ + +for (const let of []) {} diff --git a/test/language/statements/for-of/head-let-bound-names-dup.js b/test/language/statements/for-of/head-let-bound-names-dup.js new file mode 100644 index 0000000000000000000000000000000000000000..32bfb157b4767f94a3279be82aece0eb9cad3d08 --- /dev/null +++ b/test/language/statements/for-of/head-let-bound-names-dup.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The head's declaration may not contain duplicate entries +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains any + duplicate entries. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +for (let [x, x] of []) {} diff --git a/test/language/statements/for-of/head-let-bound-names-in-stmt.js b/test/language/statements/for-of/head-let-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..eababe1a3e166e6a02b485b44d334e7a3d51103f --- /dev/null +++ b/test/language/statements/for-of/head-let-bound-names-in-stmt.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may not re-declare variables declared in the head +negative: SyntaxError +info: | + It is a Syntax Error if any element of the BoundNames of ForDeclaration + also occurs in the VarDeclaredNames of Statement. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +for (let x of []) { + var x; +} diff --git a/test/language/statements/for-of/head-let-bound-names-let.js b/test/language/statements/for-of/head-let-bound-names-let.js new file mode 100644 index 0000000000000000000000000000000000000000..bff8bdbf56777a08e71a04f0f57de534c9ffe3cf --- /dev/null +++ b/test/language/statements/for-of/head-let-bound-names-let.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The declaration may not contain a binding for `let` +negative: SyntaxError +info: | + It is a Syntax Error if the BoundNames of ForDeclaration contains "let". +flags: [noStrict] +esid: sec-for-in-and-for-of-statements +es6id: 13.7.5 +---*/ + +for (let let of []) {} diff --git a/test/language/statements/for-of/head-lhs-cover-non-asnmt-trgt.js b/test/language/statements/for-of/head-lhs-cover-non-asnmt-trgt.js new file mode 100644 index 0000000000000000000000000000000000000000..7f7749ec7982c2259473c9b8edcb9be4a1555f87 --- /dev/null +++ b/test/language/statements/for-of/head-lhs-cover-non-asnmt-trgt.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Head's LeftHandSideExpression must be a simple assignment target +info: > + It is a Syntax Error if IsValidSimpleAssignmentTarget of + LeftHandSideExpression is false. + + It is a Syntax Error if the LeftHandSideExpression is + CoverParenthesizedExpressionAndArrowParameterList : ( Expression ) and + Expression derives a production that would produce a Syntax Error according + to these rules if that production is substituted for + LeftHandSideExpression. This rule is recursively applied. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for ((this) of []) {} diff --git a/test/language/statements/for-of/head-lhs-cover.js b/test/language/statements/for-of/head-lhs-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..16ba60dc604799f184276e9b15e144204a91a03c --- /dev/null +++ b/test/language/statements/for-of/head-lhs-cover.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Head's AssignmentExpression may be CoverParenthesizedExpressionAndArrowParameterList +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; +var x; + +for ((x) of [23]) { + assert.sameValue(x, 23); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-of/head-lhs-invalid-asnmt-ptrn-ary.js b/test/language/statements/for-of/head-lhs-invalid-asnmt-ptrn-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..cde3f4ed2f58d404cc29bc63954c2633025465f8 --- /dev/null +++ b/test/language/statements/for-of/head-lhs-invalid-asnmt-ptrn-ary.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invalid destructuring assignment pattern (array literal) +info: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for ([(x, y)] of []) {} diff --git a/test/language/statements/for-of/head-lhs-invalid-asnmt-ptrn-obj.js b/test/language/statements/for-of/head-lhs-invalid-asnmt-ptrn-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..66562b56b4cb04a9b61b288a96341913dfad7d79 --- /dev/null +++ b/test/language/statements/for-of/head-lhs-invalid-asnmt-ptrn-obj.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invalid destructuring assignment pattern (object literal) +info: > + It is a Syntax Error if LeftHandSideExpression is either an ObjectLiteral + or an ArrayLiteral and if the lexical token sequence matched by + LeftHandSideExpression cannot be parsed with no tokens left over using + AssignmentPattern as the goal symbol. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for ({ m() {} } of []) {} diff --git a/test/language/statements/for-of/head-lhs-member.js b/test/language/statements/for-of/head-lhs-member.js new file mode 100644 index 0000000000000000000000000000000000000000..fd8b5b1013ed9bc61b7855c030a6778eee45cf4d --- /dev/null +++ b/test/language/statements/for-of/head-lhs-member.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Head's AssignmentExpression may be a MemberExpression +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; +var x = {}; + +for (x.y of [23]) { + assert.sameValue(x.y, 23); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-of/head-lhs-non-asnmt-trgt.js b/test/language/statements/for-of/head-lhs-non-asnmt-trgt.js new file mode 100644 index 0000000000000000000000000000000000000000..3b0868017b3dee214d49a852eaf49a1ef1e28443 --- /dev/null +++ b/test/language/statements/for-of/head-lhs-non-asnmt-trgt.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Head's LeftHandSideExpression must be a simple assignment target +info: > + It is a Syntax Error if IsValidSimpleAssignmentTarget of + LeftHandSideExpression is false. +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +negative: SyntaxError +---*/ + +for (this of []) {} diff --git a/test/language/statements/for-of/head-var-bound-names-dup.js b/test/language/statements/for-of/head-var-bound-names-dup.js new file mode 100644 index 0000000000000000000000000000000000000000..558553447298c4175c450ec8b79b098576da7b34 --- /dev/null +++ b/test/language/statements/for-of/head-var-bound-names-dup.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The head's declaration may contain duplicate entries +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; + +for (var [x, x] of [[1, 2]]) { + assert.sameValue(x, 2); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-of/head-var-bound-names-in-stmt.js b/test/language/statements/for-of/head-var-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..22f76ae28289b4fb41f78448ae674c7f882bf6d7 --- /dev/null +++ b/test/language/statements/for-of/head-var-bound-names-in-stmt.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may re-declare variables declared in the head +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +---*/ + +var iterCount = 0; + +for (var x of [99]) { + var x; + + assert.sameValue(x, 99); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-of/head-var-bound-names-let.js b/test/language/statements/for-of/head-var-bound-names-let.js new file mode 100644 index 0000000000000000000000000000000000000000..3af7700e34a95836db563a1cff5d7e4352d18d92 --- /dev/null +++ b/test/language/statements/for-of/head-var-bound-names-let.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The head's bound names may include "let" +esid: sec-for-in-and-for-of-statements-static-semantics-early-errors +es6id: 13.7.5 +flags: [noStrict] +---*/ + +var iterCount = 0; + +for (var let of [23]) { + assert.sameValue(let, 23); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-of/labeled-fn-stmt-const.js b/test/language/statements/for-of/labeled-fn-stmt-const.js new file mode 100644 index 0000000000000000000000000000000000000000..09cd108e533630c36e411f1a89e2bb8d5938247b --- /dev/null +++ b/test/language/statements/for-of/labeled-fn-stmt-const.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (const x of []) label1: label2: function f() {} diff --git a/test/language/statements/for-of/labeled-fn-stmt-let.js b/test/language/statements/for-of/labeled-fn-stmt-let.js new file mode 100644 index 0000000000000000000000000000000000000000..a4032965e09c294fc23cb9611ba77718cbfcead3 --- /dev/null +++ b/test/language/statements/for-of/labeled-fn-stmt-let.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (let x of []) label1: label2: function f() {} diff --git a/test/language/statements/for-of/labeled-fn-stmt-lhs.js b/test/language/statements/for-of/labeled-fn-stmt-lhs.js new file mode 100644 index 0000000000000000000000000000000000000000..7873b6bd19147dcfc3061270a3796296a7f9b37e --- /dev/null +++ b/test/language/statements/for-of/labeled-fn-stmt-lhs.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (x of []) label1: label2: function f() {} diff --git a/test/language/statements/for-of/labeled-fn-stmt-var.js b/test/language/statements/for-of/labeled-fn-stmt-var.js new file mode 100644 index 0000000000000000000000000000000000000000..11c13cfb7e0f54ff51468d78d652c5421ffc4456 --- /dev/null +++ b/test/language/statements/for-of/labeled-fn-stmt-var.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (var x of []) label1: label2: function f() {} diff --git a/test/language/statements/for/head-const-bound-names-in-stmt.js b/test/language/statements/for/head-const-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..65ad8dde249303b56ce85ffe1fe4ded07181917e --- /dev/null +++ b/test/language/statements/for/head-const-bound-names-in-stmt.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may not re-declare variables declared in the head +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + It is a Syntax Error if any element of the BoundNames of LexicalDeclaration + also occurs in the VarDeclaredNames of Statement. +negative: SyntaxError +esid: sec-for-statement +es6id: 13.7.4 +---*/ + +for (const x; false; ) { + var x; +} diff --git a/test/language/statements/for/head-let-bound-names-in-stmt.js b/test/language/statements/for/head-let-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..e026d4edf8a094348e8d3e1391059e9a2b80ef96 --- /dev/null +++ b/test/language/statements/for/head-let-bound-names-in-stmt.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may not re-declare variables declared in the head +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + It is a Syntax Error if any element of the BoundNames of LexicalDeclaration + also occurs in the VarDeclaredNames of Statement. +negative: SyntaxError +esid: sec-for-statement +es6id: 13.7.4 +---*/ + +for (let x; false; ) { + var x; +} diff --git a/test/language/statements/for/head-var-bound-names-in-stmt.js b/test/language/statements/for/head-var-bound-names-in-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..9565ee3db05d1f46485839c27445121ffe746c1d --- /dev/null +++ b/test/language/statements/for/head-var-bound-names-in-stmt.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: The body may re-declare variables declared in the head +esid: sec-for-statement +es6id: 13.7.4 +---*/ + +var iterCount = 0; +var first = true; + +for (var x; first; first = false) { + var x; + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for/labeled-fn-stmt-const.js b/test/language/statements/for/labeled-fn-stmt-const.js new file mode 100644 index 0000000000000000000000000000000000000000..ec6bfccffa15ae1361e7f9cd78166f28f0b1e162 --- /dev/null +++ b/test/language/statements/for/labeled-fn-stmt-const.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (const x; false; ) label1: label2: function f() {} diff --git a/test/language/statements/for/labeled-fn-stmt-expr.js b/test/language/statements/for/labeled-fn-stmt-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..80cd61dcd1bd7627bf67e09fdf61b8727a672ef7 --- /dev/null +++ b/test/language/statements/for/labeled-fn-stmt-expr.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for ( ; false; ) label1: label2: function f() {} diff --git a/test/language/statements/for/labeled-fn-stmt-let.js b/test/language/statements/for/labeled-fn-stmt-let.js new file mode 100644 index 0000000000000000000000000000000000000000..9ac16eaf56552b49e0622ad33a02ab8ff5618ef6 --- /dev/null +++ b/test/language/statements/for/labeled-fn-stmt-let.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (let x; false; ) label1: label2: function f() {} diff --git a/test/language/statements/for/labeled-fn-stmt-var.js b/test/language/statements/for/labeled-fn-stmt-var.js new file mode 100644 index 0000000000000000000000000000000000000000..58c08f623abb6a1fb51c59d3fc56b112d8b1aa86 --- /dev/null +++ b/test/language/statements/for/labeled-fn-stmt-var.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +for (var x; false; ) label1: label2: function f() {} diff --git a/test/language/statements/while/labeled-fn-stmt.js b/test/language/statements/while/labeled-fn-stmt.js new file mode 100644 index 0000000000000000000000000000000000000000..e82e9318740b4506151c44d62015a0c4ccd3aa1e --- /dev/null +++ b/test/language/statements/while/labeled-fn-stmt.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: It is a Syntax Error if IsLabelledFunction(Statement) is true. +negative: SyntaxError +esid: sec-semantics-static-semantics-early-errors +es6id: 13.7.1.1 +info: > + Although Annex B describes an extension which permits labelled function + declarations outside of strict mode, this early error is applied regardless + of the language mode. +---*/ + +while (false) label1: label2: function f() {}