diff --git a/test/language/statements/for-in/head-decl-expr.js b/test/language/statements/for-in/head-decl-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..fed986ef72cbea1b034763e530d3f1f6e1a9b333 --- /dev/null +++ b/test/language/statements/for-in/head-decl-expr.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: Expression is allowed in head +info: > + IterationStatement : for ( ForDeclaration in Expression ) Statement + + 1. Let keyResult be the result of performing + ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, Expression, + enumerate). + 2. ReturnIfAbrupt(keyResult). + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). +es6id: 13.7.5.11 +---*/ + +var iterCount = 0; + +for (let x in null, { key: 0 }) { + assert.sameValue(x, 'key'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/head-expr-expr.js b/test/language/statements/for-in/head-expr-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..2a2d81828acec7e673965d11eda1aaa7694eeeaf --- /dev/null +++ b/test/language/statements/for-in/head-expr-expr.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Expression is allowed in head +info: > + IterationStatement : for ( ForDeclaration in Expression ) Statement + + 1. Let keyResult be the result of performing + ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, Expression, + enumerate). + 2. ReturnIfAbrupt(keyResult). + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). +es6id: 13.7.5.11 +---*/ + +var iterCount = 0; +var x; + +for (x in null, { key: 0 }) { + assert.sameValue(x, 'key'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-in/head-var-expr.js b/test/language/statements/for-in/head-var-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..620ba5362da1e4445733196bbfd9aae1027e4924 --- /dev/null +++ b/test/language/statements/for-in/head-var-expr.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: Expression is allowed in head +info: > + IterationStatement : for ( ForDeclaration in Expression ) Statement + + 1. Let keyResult be the result of performing + ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, Expression, + enumerate). + 2. ReturnIfAbrupt(keyResult). + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). +es6id: 13.7.5.11 +---*/ + +var iterCount = 0; + +for (var x in null, { key: 0 }) { + assert.sameValue(x, 'key'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1); diff --git a/test/language/statements/for-of/head-decl-no-expr.js b/test/language/statements/for-of/head-decl-no-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..01da99998f6feaa43f59273110a0dbb5124fc7df --- /dev/null +++ b/test/language/statements/for-of/head-decl-no-expr.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: Expression not allowed in head's AssignmentExpression position +info: > + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement +es6id: 13.7 +negative: SyntaxError +---*/ + +for (let x of [], []) {} diff --git a/test/language/statements/for-of/head-expr-no-expr.js b/test/language/statements/for-of/head-expr-no-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..14e8e47bc430c5c522d9006a3bdb734e9ff5116e --- /dev/null +++ b/test/language/statements/for-of/head-expr-no-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: Expression not allowed in head's AssignmentExpression position +info: > + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement +es6id: 13.7 +negative: SyntaxError +---*/ + +var x; +for (x of [], []) {} diff --git a/test/language/statements/for-of/head-var-no-expr.js b/test/language/statements/for-of/head-var-no-expr.js new file mode 100644 index 0000000000000000000000000000000000000000..f2de943db97dd668bb01c29de6f96723844dc187 --- /dev/null +++ b/test/language/statements/for-of/head-var-no-expr.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: Expression not allowed in head's AssignmentExpression position +info: > + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement +es6id: 13.7 +negative: SyntaxError +---*/ + +for (var x of [], []) {}