diff --git a/test/language/expressions/async-generator/named-yield-identifier-non-strict.js b/test/language/expressions/async-generator/named-yield-identifier-non-strict.js new file mode 100644 index 0000000000..5f78d6de9f --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-identifier-non-strict.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-expression-named.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator named expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) +}; + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-identifier-spread-non-strict.js b/test/language/expressions/async-generator/named-yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..ec4367a706 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-identifier-spread-non-strict.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-expression-named.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator named expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +features: [object-spread] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } +}; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0 }); +iter.next({ y: 20, a: 1, b: 1 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(Object.keys(value).length, 5); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-identifier-spread-strict.js b/test/language/expressions/async-generator/named-yield-identifier-spread-strict.js new file mode 100644 index 0000000000..f022c50e3f --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-identifier-spread-strict.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-identifier-strict.js b/test/language/expressions/async-generator/named-yield-identifier-strict.js new file mode 100644 index 0000000000..a49291637b --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-identifier-strict.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Named async generator expression) +esid: prod-AsyncGeneratorExpression +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-spread-arr-multiple.js b/test/language/expressions/async-generator/named-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..89900d9c06 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-spread-arr-multiple.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Use yield value in a array spread position (Named async generator expression) +esid: prod-AsyncGeneratorExpression +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield [...yield yield]; +}; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-spread-arr-single.js b/test/language/expressions/async-generator/named-yield-spread-arr-single.js new file mode 100644 index 0000000000..a6b0438d03 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-spread-arr-single.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Use yield value in a array spread position (Named async generator expression) +esid: prod-AsyncGeneratorExpression +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield [...yield]; +}; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-spread-obj.js b/test/language/expressions/async-generator/named-yield-spread-obj.js new file mode 100644 index 0000000000..a4baf2566c --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-spread-obj.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Use yield value in a object spread position (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-identifier-non-strict.js b/test/language/expressions/async-generator/yield-identifier-non-strict.js new file mode 100644 index 0000000000..8708e371d9 --- /dev/null +++ b/test/language/expressions/async-generator/yield-identifier-non-strict.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-expression.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) +}; + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-identifier-spread-non-strict.js b/test/language/expressions/async-generator/yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..98b6583fab --- /dev/null +++ b/test/language/expressions/async-generator/yield-identifier-spread-non-strict.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-expression.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator expression - valid for non-strict only cases) +esid: prod-AsyncGeneratorExpression +features: [object-spread] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } +}; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0 }); +iter.next({ y: 20, a: 1, b: 1 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(Object.keys(value).length, 5); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-identifier-spread-strict.js b/test/language/expressions/async-generator/yield-identifier-spread-strict.js new file mode 100644 index 0000000000..1e332e136e --- /dev/null +++ b/test/language/expressions/async-generator/yield-identifier-spread-strict.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-expression.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-identifier-strict.js b/test/language/expressions/async-generator/yield-identifier-strict.js new file mode 100644 index 0000000000..067065bb15 --- /dev/null +++ b/test/language/expressions/async-generator/yield-identifier-strict.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-expression.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-spread-arr-multiple.js b/test/language/expressions/async-generator/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..4038349475 --- /dev/null +++ b/test/language/expressions/async-generator/yield-spread-arr-multiple.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-expression.template +/*--- +description: Use yield value in a array spread position (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield [...yield yield]; +}; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-spread-arr-single.js b/test/language/expressions/async-generator/yield-spread-arr-single.js new file mode 100644 index 0000000000..45be229091 --- /dev/null +++ b/test/language/expressions/async-generator/yield-spread-arr-single.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-expression.template +/*--- +description: Use yield value in a array spread position (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield [...yield]; +}; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-spread-obj.js b/test/language/expressions/async-generator/yield-spread-obj.js new file mode 100644 index 0000000000..8f9b701a54 --- /dev/null +++ b/test/language/expressions/async-generator/yield-spread-obj.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-expression.template +/*--- +description: Use yield value in a object spread position (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-identifier-spread-strict.js b/test/language/expressions/class/async-gen-method-static-yield-identifier-spread-strict.js new file mode 100644 index 0000000000..3bd1d2095f --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-identifier-spread-strict.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-identifier-strict.js b/test/language/expressions/class/async-gen-method-static-yield-identifier-strict.js new file mode 100644 index 0000000000..a0610dabe7 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-identifier-strict.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-spread-arr-multiple.js b/test/language/expressions/class/async-gen-method-static-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..edbd643d5a --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-spread-arr-multiple.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-spread-arr-single.js b/test/language/expressions/class/async-gen-method-static-yield-spread-arr-single.js new file mode 100644 index 0000000000..f9f23472f1 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-spread-obj.js b/test/language/expressions/class/async-gen-method-static-yield-spread-obj.js new file mode 100644 index 0000000000..a2a8109fef --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-spread-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-identifier-spread-strict.js b/test/language/expressions/class/async-gen-method-yield-identifier-spread-strict.js new file mode 100644 index 0000000000..840350036e --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-identifier-spread-strict.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-identifier-strict.js b/test/language/expressions/class/async-gen-method-yield-identifier-strict.js new file mode 100644 index 0000000000..803e9f9669 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-identifier-strict.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-spread-arr-multiple.js b/test/language/expressions/class/async-gen-method-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..00040546b8 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-spread-arr-multiple.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Use yield value in a array spread position (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-spread-arr-single.js b/test/language/expressions/class/async-gen-method-yield-spread-arr-single.js new file mode 100644 index 0000000000..3bee88b77b --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Use yield value in a array spread position (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-spread-obj.js b/test/language/expressions/class/async-gen-method-yield-spread-obj.js new file mode 100644 index 0000000000..54ce456642 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-spread-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Use yield value in a object spread position (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-identifier-non-strict.js b/test/language/expressions/object/method-definition/async-gen-yield-identifier-non-strict.js new file mode 100644 index 0000000000..f6a94c40f2 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-identifier-non-strict.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-obj-method.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases) +esid: prod-AsyncGeneratorMethod +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) + } +}.method; + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-identifier-spread-non-strict.js b/test/language/expressions/object/method-definition/async-gen-yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..7bb35899c8 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-identifier-spread-non-strict.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-obj-method.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } + } +}.method; + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0 }); +iter.next({ y: 20, a: 1, b: 1 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(Object.keys(value).length, 5); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-identifier-spread-strict.js b/test/language/expressions/object/method-definition/async-gen-yield-identifier-spread-strict.js new file mode 100644 index 0000000000..cacb1efb64 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-identifier-spread-strict.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } +}.method; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-identifier-strict.js b/test/language/expressions/object/method-definition/async-gen-yield-identifier-strict.js new file mode 100644 index 0000000000..e1360accb8 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-identifier-strict.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async generator method) +esid: prod-AsyncGeneratorMethod +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +---*/ + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } +}.method; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js b/test/language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..bbd66a65c2 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-spread-arr-multiple.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Use yield value in a array spread position (Async generator method) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield [...yield yield]; + } +}.method; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js b/test/language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js new file mode 100644 index 0000000000..1650fce4cd --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-spread-arr-single.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Use yield value in a array spread position (Async generator method) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield [...yield]; + } +}.method; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-spread-obj.js b/test/language/expressions/object/method-definition/async-gen-yield-spread-obj.js new file mode 100644 index 0000000000..76655d4c22 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-spread-obj.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Use yield value in a object spread position (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } +}.method; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-identifier-non-strict.js b/test/language/statements/async-generator/yield-identifier-non-strict.js new file mode 100644 index 0000000000..292b4f00c3 --- /dev/null +++ b/test/language/statements/async-generator/yield-identifier-non-strict.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-non-strict.case +// - src/async-generators/non-strict/async-declaration.template +/*--- +description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator function declaration - valid for non-strict only cases) +esid: prod-AsyncGeneratorDeclaration +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +async function *gen() { + callCount += 1; + return (function(arg) { + var yield = arg + 1; + return yield; + }(yield)) +} + +var iter = gen(); + +var item = iter.next(); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value, undefined); +}); + +item = iter.next(42); + +item.then(({ done, value }) => { + assert.sameValue(done, true); + assert.sameValue(value, 43); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-identifier-spread-non-strict.js b/test/language/statements/async-generator/yield-identifier-spread-non-strict.js new file mode 100644 index 0000000000..35c9b4fa92 --- /dev/null +++ b/test/language/statements/async-generator/yield-identifier-spread-non-strict.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-non-strict.case +// - src/async-generators/non-strict/async-declaration.template +/*--- +description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator function declaration - valid for non-strict only cases) +esid: prod-AsyncGeneratorDeclaration +features: [object-spread] +flags: [generated, noStrict, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield { + ...yield yield, + ...(function(arg) { + var yield = arg; + return {...yield}; + }(yield)), + ...yield, + } +} + +var iter = gen(); + +var iter = gen(); + +iter.next(); +iter.next(); +iter.next({ x: 10, a: 0, b: 0 }); +iter.next({ y: 20, a: 1, b: 1 }); +var item = iter.next({ z: 30, b: 2 }); + +item.then(({ done, value }) => { + assert.sameValue(done, false); + assert.sameValue(value.x, 10); + assert.sameValue(value.y, 20); + assert.sameValue(value.z, 30); + assert.sameValue(value.a, 1); + assert.sameValue(value.b, 2); + assert.sameValue(Object.keys(value).length, 5); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-identifier-spread-strict.js b/test/language/statements/async-generator/yield-identifier-spread-strict.js new file mode 100644 index 0000000000..6b1ec3cac8 --- /dev/null +++ b/test/language/statements/async-generator/yield-identifier-spread-strict.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-declaration.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +async function *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +} + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-identifier-strict.js b/test/language/statements/async-generator/yield-identifier-strict.js new file mode 100644 index 0000000000..1ba4d0729e --- /dev/null +++ b/test/language/statements/async-generator/yield-identifier-strict.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-declaration.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +async function *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +} + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-spread-arr-multiple.js b/test/language/statements/async-generator/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..34f0e3ef50 --- /dev/null +++ b/test/language/statements/async-generator/yield-spread-arr-multiple.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Use yield value in a array spread position (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield [...yield yield]; +} + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-spread-arr-single.js b/test/language/statements/async-generator/yield-spread-arr-single.js new file mode 100644 index 0000000000..80a9641244 --- /dev/null +++ b/test/language/statements/async-generator/yield-spread-arr-single.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Use yield value in a array spread position (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield [...yield]; +} + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-spread-obj.js b/test/language/statements/async-generator/yield-spread-obj.js new file mode 100644 index 0000000000..4ed722ea9a --- /dev/null +++ b/test/language/statements/async-generator/yield-spread-obj.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Use yield value in a object spread position (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +} + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-identifier-spread-strict.js b/test/language/statements/class/async-gen-method-static-yield-identifier-spread-strict.js new file mode 100644 index 0000000000..58a66025e1 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-identifier-spread-strict.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-identifier-strict.js b/test/language/statements/class/async-gen-method-static-yield-identifier-strict.js new file mode 100644 index 0000000000..9609478ee0 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-identifier-strict.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-spread-arr-multiple.js b/test/language/statements/class/async-gen-method-static-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..9f69ae6fd2 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-spread-arr-multiple.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-spread-arr-single.js b/test/language/statements/class/async-gen-method-static-yield-spread-arr-single.js new file mode 100644 index 0000000000..3df12ef903 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-spread-obj.js b/test/language/statements/class/async-gen-method-static-yield-spread-obj.js new file mode 100644 index 0000000000..526bb2b937 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-spread-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-identifier-spread-strict.js b/test/language/statements/class/async-gen-method-yield-identifier-spread-strict.js new file mode 100644 index 0000000000..bfee4d874d --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-identifier-spread-strict.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-identifier-strict.js b/test/language/statements/class/async-gen-method-yield-identifier-strict.js new file mode 100644 index 0000000000..8f6d71e7e6 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-identifier-strict.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +flags: [generated, onlyStrict] +negative: + phase: early + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +---*/ + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-spread-arr-multiple.js b/test/language/statements/class/async-gen-method-yield-spread-arr-multiple.js new file mode 100644 index 0000000000..a32b600497 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-spread-arr-multiple.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-spread-arr-single.js b/test/language/statements/class/async-gen-method-yield-spread-arr-single.js new file mode 100644 index 0000000000..0a34a9577e --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-spread-arr-single.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-spread-obj.js b/test/language/statements/class/async-gen-method-yield-spread-obj.js new file mode 100644 index 0000000000..ffbb519675 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-spread-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Use yield value in a object spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1);