diff --git a/test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..a983cf4cd50409ad1cda6d3e79fa2826c766bb78 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting done (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..0dcffdf4016af1b95b8b5338bade45c6c2386e76 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while calling next (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..bb072bb3e2ee511c6bdee2e5667df07eb14824c9 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..e4b7bdd8f0f002fa97d3812a929c45b587369f4d --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Abrupt completion while getting next (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js b/test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..081f9a31c1648eac511277ac8117f71bc8b62b50 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: If next() value is not-object, do not access respective then property (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..99a9e326f2785d3010e580d4027c5aaabbcebad0 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - boolean (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..f0ad070fd69e548bed60e5c397c3970cda4e1a99 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - null (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c6c28e3a744b7915fcd446b292e0fce8226b160c --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - number (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..45b7aee7d0d7441e58f6aa90708af744f2ebc14c --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - object (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3b48b33b9301776ec5cff8b3d056665c8d48cdf6 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - string (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..58b697b586b5fe08a36a0f805e938b9ac4ee99b6 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - symbol (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..eec2fd2f698fff06230fe670116f5a161614d871 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Not-callable next value in a yield star position - undefined (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..1ba4fd88ebf32a1ea195d7074ab38511301b0221 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Return abrupt after getting next().then (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6f5c95af4edb2ee42ba0d6526cafa6ae4a9c2012 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..b223de5bf2e2ff307c42703b79e08decca36eb03 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..c995892b981382db77fe06f3f36d8389d80636ee --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..2b9925d99698b0b836f0a9df77964dbc7336fccc --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..ec4b195a5d85f5aeb5460662ace5efafd93f24e8 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..fcefe679daf68dc269b6eaabfd82448995ac118a --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..76a8b7b92aa10e0a226ef6e46d1fe4e7bf536f63 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js b/test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..715883c430b428dfab631b536134f16600e2e4a5 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: Return abrupt after calling next().then (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d4f3c92221dcfd60c995b2cc1f879186037a9fd3 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting done (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js b/test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..25ba0d7adb0e566c4333874902300d1252275b36 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while calling next (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..0f81e4fef70a1a229146f6e7457dfae12713ec49 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..64553662aa4e491c757249aed27044a0394a0977 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Abrupt completion while getting next (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js b/test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..775391dcd57a9bb0d3da0bb3988b4a137ff78c2b --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-expression.template +/*--- +description: If next() value is not-object, do not access respective then property (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e6bf37f887eb9b7776b3aaa711903b67c2320586 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - boolean (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..1cc10d2afe276d3970d97187a34de751ced0c24a --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - null (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..04737bcb12fcbb6d93dc483a92ebb36fabb8a9bd --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - number (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..dae130da847b347c4352874ebab96e463e58fcc7 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - object (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c07e55cd7e7b2c9f921f2151f2302f7c8a51e38b --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - string (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6eb39b2024279c218284735bc168422cdc09891e --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - symbol (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..5a4e50258fc895f987a6e1449b03e7facd3a4190 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-expression.template +/*--- +description: Not-callable next value in a yield star position - undefined (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js b/test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..4af4b576721b79d3b52c351cfc4694c2274f26b2 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Return abrupt after getting next().then (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..0c685accb3140ab96a6e164facb471f4e0b867f5 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..d6919d6e7614e448b32fc4c1aac0ba1cd06aa14c --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..ee3a16ac58d348ac511d22e122c383d65c1dfe77 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..0610e3f3f291fcdc3f76aa58f40fd146e5028d3e --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6d2b3b9ab169804071eaf047811d908854c85e46 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..86d5c8a710b65723223e5e9cfd8968d481690680 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..17ad83c612db144a437881e46811cf802a972382 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-expression.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js b/test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..4391180d1c873f32999e94fc26a93940edc76112 --- /dev/null +++ b/test/language/expressions/async-generator/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-expression.template +/*--- +description: Return abrupt after calling next().then (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..89e0163347748d12a54e0fbd18ae7a5cce1f0f17 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..f2972dc1f1cc70a177f86d6a821e7d5ec2619ca6 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2c4e517f59a492b028a7fb80895d8173fb5ae8b3 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..30d17b536d9019dc7b65297e598c3ec373a3a6fa --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..47f1aa0e662b0f30c68d0ca6c0278b0b5eaf4808 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..abc2f3b8e8a267ce72a32ba4614533c0fcdb7ff0 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..1cb37d6792223c1d052c0ff5c2a9ef5826b3fb69 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7c34852b71e15c43a699265ffb997c322395b43d --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..aed54bd2c3df04478737e0625a5989db5894c102 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6f5e6b03742118fc9d581fee7d1541d509ffbe68 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8ff634774c136f445cd69b60840a5ddc144b4717 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc1c8adc22913d9106e89df7e9a7c1e00e8e40f --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..7f117b6b74846f0ae5357450633618d12a7c585c --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..bef481f83cabf2f1d401b18101618bfbfe1a0e67 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..8f27218b8f085b69ce4fefa12713e8a9dab60ae1 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..acefe92b02b932eeb62888d66d5bf075046a0655 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..95a5a782d7baad70a9882edded12a001d56973a1 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..c358cdab045a5cc9cca39b2e512cccd3d01022eb --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..ae2dc4be0e2a948ef0a37b7e4411465d958e6966 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..82abbf1f4e1d86a1b9a450490bcea95e23d2b03a --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..7444f6569884ad8c276cdc8d6ee1ac296dfe4935 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..62ece3d7e33dc17e7046a2850d58e787c130db85 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while getting done (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d47fe096acdeb611ce9a60a93ed19959fc036d27 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while calling next (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..802c6173065aa459056e78fcfd471bad2f3bb676 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while getting value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..3b69bae809915611ab430926d33f74c84203a478 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Abrupt completion while getting next (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js b/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..2bee89cbc229f303dc510b219023f3725bd263a8 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..75d6fa8cab0a6c80800d14bea49eb487d247c6ee --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..abf7fa7eb445b5ff0b16b2f6e3561a0621b294d8 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e305ad4dded7ca7d65f39ac8c8b2f8dfc992e8c3 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e84eb94ac022859ce18fa105a7683157bd0503ca --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c39891b8531fb7fe2dfff0a7b30444bd2c7287b0 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..970ae58679770fa02ec0a433208c350c1c3cd033 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..0f12fa66205b3b4c58676f5bb0d6a0bbe5ba3030 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..fd0c8bc4c5b3953633d1ec38449fae4d37a1bb2f --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Return abrupt after getting next().then (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..2975d1bec2b0e301c33f0c0e458f05ae1fa09335 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..2700e425d044eaf07fcf1ea2327d20fed5a138c0 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..d0e25849d2a36619c0386e4e7b3952fa00c72650 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..0b2420c1f6af84ee556e81ba8602662d25760338 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..87472a33aa693e10af2fbc5fb7e56f3e65a3a1eb --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..b03b7fd2d9a065b1ad8e9041b8899825dec407ca --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6e038598dcd395355d65b0e73e9583825e0b5c90 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js b/test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d34cfc2e9822bcdf936bae325296aeafdc8abf44 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: Return abrupt after calling next().then (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..bd8ff99b1d0be9b9b572e13d7da20cfd7c8f984d --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting done (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..ffbd025ab1f713812a76814edee15874adc59b79 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while calling next (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..266eeb21bc5efc8a3dee116c2e734611215033bd --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..23f86cb393053ed4819b6450ee99d545c0ad71cc --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Abrupt completion while getting next (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..5e154af2b736da0064b2f86caccd141d66e1f927 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c4546d18ee731d285aa598b13d6fb3946a375d5a --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..12f5d296eed2d323e3c9f7e19bf6dd81a64427b8 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..dbb1ae94d9928f79db9433ddde6894a20619dcc5 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7fddd5bd23cb5966f128151626ec9b394d785e34 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..62cf0392820a48572614ce91b8c093c8685117f5 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..07fc007f648b14b03ca961dd6de7a7ecfc8cee03 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..9fad5f605f095a63c55c531ea03057cf15c5558f --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..77943229e42e7c6a972c694df5422d17e69ecfb4 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Return abrupt after getting next().then (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..755b9068f8260e3ffc22ab3588a61882be645eeb --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..47faa7471ab7e8cc4eccdca0bf3145ad5965995e --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..fc74bf79428814e3e21f12ff5b201c65ca6490a3 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..cd9d211867412385e94a70cffdfd20271d8afd92 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f3f7a18268d79ac341d6503df5c2645dbe20c045 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..3322d59b91516ff6ab422aecd90747e6787c678b --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..38a1641585b01ed0dd218ab8b0732ab96dada887 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..b69abcfabc94525473309ea5834b455e47675754 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: Return abrupt after calling next().then (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..c13ed8b6eecc66b1c2cc8f3747b3630c5aaec2ee --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while getting done (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js b/test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..32d9bb485ff242598dd0afbf808e74e474cf097d --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while calling next (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..07a2fabc71010598ddce822ed9fa7c4520e992cb --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while getting value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..a03caa24577d704ccf8928a47f27092b9d8a33ae --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-get-abrupt.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Abrupt completion while getting next (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js b/test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..4731c17dbec8a4c974257a24fbea7da9b0266e10 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-declaration.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4cb2ca81e66f1c1d725de8a3dee50e2e10a92a0c --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..60d8eaaf7f753049f92981d449f2699028ee409e --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7dec927b81a2a170d7aa106cd80a22c5d86c0a07 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..1c70464a1c851b820616892b41bee6e614741c51 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3a9ff2b1d0ee8e7312321dae57184129992fbe65 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7b57f326a39a6ea479fcf7a775500c8e800469d4 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js b/test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..496680b6f2b5f733c6c9d0f56dfed17d4c6f46ce --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-get-abrupt.js b/test/language/statements/async-generator/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..15e2451787b0b9c2e5e8e8c1b11abc0fab577fc9 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Return abrupt after getting next().then (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..e4baa841feb8dc0de1df1c1f11b3874fb2dc1cc5 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..bb6b53dbaca11b114dcc5f473e06991fb80b6f55 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..898cb85c7b94c9ca01778a0830bfc2a31e6b92ed --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..a1cf87576785c32f184da8077e0b0d79c85bcaa9 --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..a9de651f5daf870ce77cee87a3d033a3b192565a --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..9b7414d03b4b0330262c5e80612111b8de571d8c --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..76b7307eb942eab7437c4c5527123b635bbfabfb --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-declaration.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js b/test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..18d1b45231405990dd4a8e4bb7d7dcad3aecddaf --- /dev/null +++ b/test/language/statements/async-generator/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-declaration.template +/*--- +description: Return abrupt after calling next().then (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..53ae856b4dc1f447bb86093f8128e58052bf426d --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d0c2b5d6d76168d42ac954862362c99948c08c2e --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..96ecd99ad852427abb33062ecbe273ba77611729 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..621ee58ceb5549bfb0266be8c3614bcabf03c742 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js b/test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..db0d0499e931bcbda95d2e97ec0525845636bd08 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..9989ea6d4159e1196c3f2e8c8292cbff3a053e1e --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b0c14146e2b1d95ea56a492eaece26b6dfa5982d --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..13d8ce91bfe8e62beea3916361e659c929e49ea4 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4263df16a801848895539751c0f6dde5ceaf9a6d --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..0974eb5dae1622452c61575f6a6f9fd72c12fc96 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6098c1c85b1ce8701a26fe02de710ed6764d6429 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..67b0e6d5ab520223af5153f6741931377da20b17 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..5cce8661a8eb1058de57ccdb741d8aba67f3c2a3 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f141e2e8fc9d250ed8a1bc54d8be7c4b02ca799e --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..d322511143409746190649d7bad960a871c56a7d --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..bff54ade5b0563571898c85ebb1f453c47622da3 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..7203befcf00f94c8f3c5dae3b99aa389a13df026 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..a219952e332eb5bbe1ed15b62ee780119d96e701 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..7b6799bedb89d2314279190b35a7d6470cd9d038 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..64c19d4bcae1b34874555c4811c46157fd3f60b0 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js b/test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..91f46489198392cdba13746b3a1793ca56b24af3 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..e4c670ff19a40e7c64c7c254c867c4d8d826e7fa --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting done (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..c1660b888c1c50b764aeefea0f87c4916c9074cb --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while calling next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..04ead08fda457a490c59ed172bf2034e785acd06 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..ede7d25b9dc8ce7d5dffe32327b1a0e779e92a94 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-get-abrupt.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js b/test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..dd4a92ba15eae79d35fa0bbdf3f0b4c3e0697293 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..bb7ae187172dd1fe80a68c36af8e5fe28aec55f5 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..79032029b43ee64d21beaa517fcdcd1c2884692a --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..f16689a758d5b2ad4c8e57d92455f0eba26f9212 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..2a210a48228b2f507327361f4e7e6ce4626e543e --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..f8bc989bd8d8c87e5e95f18237bf1a8343ebf921 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7c39e43f31a0b240291763b081bc5a8dac3cbf0a --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..334f8fe1707527a3d5b1d42d6438a359bbaebaf8 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..8151a2af33ed5a56a9e905d20625f9d08e5dd502 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-get-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Return abrupt after getting next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..275c1f79ff27703f2278c28ea8b8bfa53989e7f3 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..fbfdaff67d73dc9803f64230eeb12875087baacd --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..cb08503ac65bbeecae16bee92feb2a74be11c3df --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..137156769e9bd1f5690fef1b686889af845e7005 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..2e15e7ad93ec7fa82a6a6bc062da0a6212c744c9 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..ee4e4dba3a2372795abc387c28b2aaf368ff3756 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..21dfa1d6a57abfbfb8cbb4e94018dae2dea824e7 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js b/test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d1cafe17cc07f8aa6ed3e3648baf1dca7530cb2f --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Return abrupt after calling next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1);