diff --git a/test/language/identifiers/yield-as-binding-identifier-in-strict.js b/test/language/identifiers/yield-as-binding-identifier-in-strict.js new file mode 100644 index 0000000000..e29ebd50c9 --- /dev/null +++ b/test/language/identifiers/yield-as-binding-identifier-in-strict.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved identifier in strict mode code and may not be used + as an identifier. + es6id: 12.1.1 + negative: SyntaxError + flags: [onlyStrict] + ---*/ + +var yield = 13; diff --git a/test/language/identifiers/yield-as-key.js b/test/language/identifiers/yield-as-key.js new file mode 100644 index 0000000000..a2ef0d5c45 --- /dev/null +++ b/test/language/identifiers/yield-as-key.js @@ -0,0 +1,10 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal. + es6id: 12.1.1 + ---*/ + +({ yield: 1 }); diff --git a/test/language/identifiers/yield-as-label-in-sloppy.js b/test/language/identifiers/yield-as-label-in-sloppy.js new file mode 100644 index 0000000000..a2501aa091 --- /dev/null +++ b/test/language/identifiers/yield-as-label-in-sloppy.js @@ -0,0 +1,12 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is not a reserved identifier in non-strict mode code and may be + used as a label. + es6id: 12.1.1 + flags: [noStrict] + ---*/ + +yield: 1; diff --git a/test/language/identifiers/yield-as-label-in-strict.js b/test/language/identifiers/yield-as-label-in-strict.js new file mode 100644 index 0000000000..855a0aa088 --- /dev/null +++ b/test/language/identifiers/yield-as-label-in-strict.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved identifier in strict mode code and may not be used + as a label. + es6id: 12.1.1 + negative: SyntaxError + flags: [onlyStrict] + ---*/ + +yield: 1; diff --git a/test/language/statements/generators/no-yield.js b/test/language/statements/generators/no-yield.js new file mode 100644 index 0000000000..1c4366e982 --- /dev/null +++ b/test/language/statements/generators/no-yield.js @@ -0,0 +1,16 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Generators declared with GeneratorDeclaration syntax do not require a + `yield` expression. + es6id: 14.4 + ---*/ + +function *foo(a) {} + +var g = foo(3); + +assert.sameValue(g.next().value, undefined); +assert.sameValue(g.next().done, true); diff --git a/test/language/statements/generators/return.js b/test/language/statements/generators/return.js new file mode 100644 index 0000000000..8ffb3e17f9 --- /dev/null +++ b/test/language/statements/generators/return.js @@ -0,0 +1,11 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `return` is a valid statement within generator function bodies. + es6id: 14.4 + ---*/ + +function* g() { return; } +function* g() { return 1; } diff --git a/test/language/statements/generators/yield-as-binding-identifier.js b/test/language/statements/generators/yield-as-binding-identifier.js new file mode 100644 index 0000000000..e8b2c2ef55 --- /dev/null +++ b/test/language/statements/generators/yield-as-binding-identifier.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved keyword within generator function bodies and may + not be used as a binding identifier. + es6id: 12.1.1 + negative: SyntaxError + ---*/ + +function* g() { + yield = 1; +} diff --git a/test/language/statements/generators/yield-as-expression-with-rhs.js b/test/language/statements/generators/yield-as-expression-with-rhs.js new file mode 100644 index 0000000000..5022f67951 --- /dev/null +++ b/test/language/statements/generators/yield-as-expression-with-rhs.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid expression within generator function bodies. + es6id: 14.4 + ---*/ + +function* g() { (yield 1) } +function* g() { [yield 1] } +function* g() { {yield 1} } +function* g() { yield 1, yield 1; } +function* g() { (yield 1) ? yield 1 : yield 1 } diff --git a/test/language/statements/generators/yield-as-expression-without-rhs.js b/test/language/statements/generators/yield-as-expression-without-rhs.js new file mode 100644 index 0000000000..63b9b22948 --- /dev/null +++ b/test/language/statements/generators/yield-as-expression-without-rhs.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid expression within generator function bodies. + es6id: 14.4 + ---*/ + +function* g() { (yield) } +function* g() { [yield] } +function* g() { {yield} } +function* g() { yield, yield; } +function* g() { (yield) ? yield : yield } diff --git a/test/language/statements/generators/yield-as-function-expression-binding-identifier.js b/test/language/statements/generators/yield-as-function-expression-binding-identifier.js new file mode 100644 index 0000000000..08b06d5a1a --- /dev/null +++ b/test/language/statements/generators/yield-as-function-expression-binding-identifier.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as the binding identifier of a function expression + within generator bodies. + es6id: 14.1 + flags: [noStrict] + ---*/ + +function* g() { + (function yield() {}) +} diff --git a/test/language/statements/generators/yield-as-generator-declaration-binding-identifier.js b/test/language/statements/generators/yield-as-generator-declaration-binding-identifier.js new file mode 100644 index 0000000000..eea595ea0c --- /dev/null +++ b/test/language/statements/generators/yield-as-generator-declaration-binding-identifier.js @@ -0,0 +1,12 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid BindingIdentifier for GeneratorDeclarations outside of + strict mode. + es6id: 12.1.1 + flags: [noStrict] + ---*/ + +function* yield() { (yield 3) + (yield 4); } diff --git a/test/language/statements/generators/yield-as-identifier-in-nested-function.js b/test/language/statements/generators/yield-as-identifier-in-nested-function.js new file mode 100644 index 0000000000..438fe55e23 --- /dev/null +++ b/test/language/statements/generators/yield-as-identifier-in-nested-function.js @@ -0,0 +1,16 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is not a reserved keyword within normal function bodies declared + within generator function bodies. + es6id: 12.1.1 + flags: [noStrict] + ---*/ + +function* g() { + function h() { + yield = 1; + } +} diff --git a/test/language/statements/generators/yield-as-label.js b/test/language/statements/generators/yield-as-label.js new file mode 100644 index 0000000000..21ad2760c4 --- /dev/null +++ b/test/language/statements/generators/yield-as-label.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved keyword within generator function bodies and may + not be used as a label. + es6id: 12.1.1 + negative: SyntaxError + ---*/ + +function* g() { + yield: 1; +} diff --git a/test/language/statements/generators/yield-as-literal-property-name.js b/test/language/statements/generators/yield-as-literal-property-name.js new file mode 100644 index 0000000000..3b2555e387 --- /dev/null +++ b/test/language/statements/generators/yield-as-literal-property-name.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal + within generator function bodies. + es6id: 12.1.1 + ---*/ + +function* g() { + ({ get yield() { return 1 } }); +} diff --git a/test/language/statements/generators/yield-as-logical-or-expression.js b/test/language/statements/generators/yield-as-logical-or-expression.js new file mode 100644 index 0000000000..2ebb34402f --- /dev/null +++ b/test/language/statements/generators/yield-as-logical-or-expression.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions are not LogicalOrExpressions. + es6id: 12.1.1 + negative: SyntaxError + ---*/ + + +function* g() { + yield ? yield : yield +} diff --git a/test/language/statements/generators/yield-as-parameter.js b/test/language/statements/generators/yield-as-parameter.js new file mode 100644 index 0000000000..0b7c04ba05 --- /dev/null +++ b/test/language/statements/generators/yield-as-parameter.js @@ -0,0 +1,12 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved keyword within generator function bodies and may + not be used as the binding identifier of a parameter. + es6id: 12.1.1 + negative: SyntaxError + ---*/ + +function* g(yield) {} diff --git a/test/language/statements/generators/yield-as-property-name.js b/test/language/statements/generators/yield-as-property-name.js new file mode 100644 index 0000000000..d3a584a674 --- /dev/null +++ b/test/language/statements/generators/yield-as-property-name.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal + within generator function bodies. + es6id: 12.1.1 + ---*/ + +function* g() { + ({ yield: 1 }); +} diff --git a/test/language/statements/generators/yield-as-statement.js b/test/language/statements/generators/yield-as-statement.js new file mode 100644 index 0000000000..d76b027941 --- /dev/null +++ b/test/language/statements/generators/yield-as-statement.js @@ -0,0 +1,11 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid statement within generator function bodies. + es6id: 14.4 + ---*/ + +function* g() { yield; } +function* g() { yield 1; } diff --git a/test/language/statements/generators/yield-as-yield-operand.js b/test/language/statements/generators/yield-as-yield-operand.js new file mode 100644 index 0000000000..00815fc27f --- /dev/null +++ b/test/language/statements/generators/yield-as-yield-operand.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions may be used as the right-hand-side of other `yield` + expressions. + es6id: 14.4 + ---*/ + +function* g() { + yield yield 1; +} diff --git a/test/language/statements/generators/yield-newline.js b/test/language/statements/generators/yield-newline.js new file mode 100644 index 0000000000..b4153832cb --- /dev/null +++ b/test/language/statements/generators/yield-newline.js @@ -0,0 +1,15 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Newlines terminate `yield` expressions. + es6id: 14.4 + ---*/ + +function* g() { + yield + 1 +} + +assert.sameValue(g().next().value, undefined); diff --git a/test/language/statements/generators/yield-star-after-newline.js b/test/language/statements/generators/yield-star-after-newline.js new file mode 100644 index 0000000000..0f4f65c558 --- /dev/null +++ b/test/language/statements/generators/yield-star-after-newline.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + A newline may not precede the `*` token in a `yield` expression. + es6id: 14.4 + negative: SyntaxError + ---*/ + +function* g() { + yield + * 1 +} diff --git a/test/language/statements/generators/yield-star-before-newline.js b/test/language/statements/generators/yield-star-before-newline.js new file mode 100644 index 0000000000..3f3ab2f40d --- /dev/null +++ b/test/language/statements/generators/yield-star-before-newline.js @@ -0,0 +1,13 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + The right-hand side of a `yield *` expression may appear on a new line. + es6id: 14.4 + ---*/ + +function* g() { + yield * + 1 +} diff --git a/test/language/statements/generators/yield-weak-binding.js b/test/language/statements/generators/yield-weak-binding.js new file mode 100644 index 0000000000..6fab61a33c --- /dev/null +++ b/test/language/statements/generators/yield-weak-binding.js @@ -0,0 +1,11 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions bind weakly + es6id: 14.4 + negative: SyntaxError + ---*/ + +function* g() { yield 3 + yield 4; }