diff --git a/src/async-generators/yield-promise-reject-next-catch.case b/src/async-generators/yield-promise-reject-next-catch.case new file mode 100644 index 0000000000..bc05681339 --- /dev/null +++ b/src/async-generators/yield-promise-reject-next-catch.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: yield Promise.reject(value) is treated as throw value +template: default +flags: [async] +---*/ + +//- setup +let error = new Error(); +//- body +yield Promise.reject(error); +yield "unreachable"; +//- assertions +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); diff --git a/src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case b/src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case new file mode 100644 index 0000000000..bca3550a44 --- /dev/null +++ b/src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case @@ -0,0 +1,33 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: yield * [Promise.reject(value)] is treated as throw value +template: default +flags: [async] +---*/ + +//- setup +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} +//- body +for await (let line of readFile()) { + yield line; +} +//- assertions +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case b/src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case new file mode 100644 index 0000000000..19774b0943 --- /dev/null +++ b/src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: yield Promise.reject(value) in for-await-of is treated as throw value +template: default +flags: [async] +---*/ + +//- setup +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; +//- body +for await (let value of iterable) { + yield value; +} +//- assertions +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case b/src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case new file mode 100644 index 0000000000..5239f6068b --- /dev/null +++ b/src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: yield * (async iterator) is treated as throw value +template: default +flags: [async] +---*/ + +//- setup +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} +//- body +yield * readFile(); + +//- assertions +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case b/src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case new file mode 100644 index 0000000000..36fb4da678 --- /dev/null +++ b/src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: yield * (async iterator) is treated as throw value +template: default +flags: [async] +---*/ + +//- setup +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; +//- body +yield * iterable; +//- assertions +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-promise-reject-next.case b/src/async-generators/yield-promise-reject-next.case new file mode 100644 index 0000000000..09a1eba754 --- /dev/null +++ b/src/async-generators/yield-promise-reject-next.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: yield Promise.reject(value) is treated as throw value +template: default +flags: [async] +---*/ + +//- setup +let error = new Error(); +//- body +yield Promise.reject(error); +yield "unreachable"; +//- assertions +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/test/language/expressions/async-generator/named-yield-promise-reject-next-catch.js b/test/language/expressions/async-generator/named-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..59d8be4235 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-promise-reject-next-catch.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..29cbdb6b5a --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..21bb881198 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..0794cd9f6c --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield * (async iterator) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield * readFile(); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..72e72df628 --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield * (async iterator) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield * iterable; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/named-yield-promise-reject-next.js b/test/language/expressions/async-generator/named-yield-promise-reject-next.js new file mode 100644 index 0000000000..ad22eb20eb --- /dev/null +++ b/test/language/expressions/async-generator/named-yield-promise-reject-next.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-expression-named.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Named async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *g() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-promise-reject-next-catch.js b/test/language/expressions/async-generator/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..e1e7551dde --- /dev/null +++ b/test/language/expressions/async-generator/yield-promise-reject-next-catch.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..8e265f1f9c --- /dev/null +++ b/test/language/expressions/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..7c98b1a8b4 --- /dev/null +++ b/test/language/expressions/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..ae21e98dff --- /dev/null +++ b/test/language/expressions/async-generator/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield * (async iterator) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield * readFile(); + +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..c910527c00 --- /dev/null +++ b/test/language/expressions/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield * (async iterator) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield * iterable; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/async-generator/yield-promise-reject-next.js b/test/language/expressions/async-generator/yield-promise-reject-next.js new file mode 100644 index 0000000000..a9bdaa6832 --- /dev/null +++ b/test/language/expressions/async-generator/yield-promise-reject-next.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-expression.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Unnamed async generator expression) +esid: prod-AsyncGeneratorExpression +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorExpression : + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var gen = async function *() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-catch.js b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..d34011e074 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-catch.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..f2b2c68d2d --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..902a52c7f8 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..9f17fe1245 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..42d7ddc978 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next.js b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next.js new file mode 100644 index 0000000000..3e5341be40 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-expr-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-promise-reject-next-catch.js b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..4be0f63cb7 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-catch.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..518ec97ca5 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..6b58961b08 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..c245cf3579 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..e17f0c12f0 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/async-gen-method-yield-promise-reject-next.js b/test/language/expressions/class/async-gen-method-yield-promise-reject-next.js new file mode 100644 index 0000000000..423a7842f6 --- /dev/null +++ b/test/language/expressions/class/async-gen-method-yield-promise-reject-next.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-expr-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..3721180ebd --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-catch.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..14906893e7 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..693da2fec7 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..26167b5f7f --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield * readFile(); + + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..7ddf2bf64f --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield * iterable; + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js new file mode 100644 index 0000000000..a4bcb40c8d --- /dev/null +++ b/test/language/expressions/object/method-definition/async-gen-yield-promise-reject-next.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-obj-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + +var callCount = 0; + +var gen = { + async *method() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } +}.method; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-promise-reject-next-catch.js b/test/language/statements/async-generator/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..b9215dbfd7 --- /dev/null +++ b/test/language/statements/async-generator/yield-promise-reject-next-catch.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-declaration.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/statements/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..f753b346f8 --- /dev/null +++ b/test/language/statements/async-generator/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-declaration.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +async function *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/statements/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..1b7c4473aa --- /dev/null +++ b/test/language/statements/async-generator/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-declaration.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +async function *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-promise-reject-next-yield-star-async-iterator.js b/test/language/statements/async-generator/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..5c455994af --- /dev/null +++ b/test/language/statements/async-generator/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-declaration.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield * readFile(); + +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/statements/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..6c01a8749c --- /dev/null +++ b/test/language/statements/async-generator/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-declaration.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield * iterable; +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/async-generator/yield-promise-reject-next.js b/test/language/statements/async-generator/yield-promise-reject-next.js new file mode 100644 index 0000000000..9e8ef58daf --- /dev/null +++ b/test/language/statements/async-generator/yield-promise-reject-next.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-declaration.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator Function declaration) +esid: prod-AsyncGeneratorDeclaration +features: [async-iteration] +flags: [generated, async] +info: | + Async Generator Function Definitions + + AsyncGeneratorDeclaration: + async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { + AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +async function *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +} + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-catch.js b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..63e9b2c427 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-catch.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..8c345c2044 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..d9b58325ef --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..ba0401d209 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..545756025b --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-static-yield-promise-reject-next.js b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next.js new file mode 100644 index 0000000000..b10840fc37 --- /dev/null +++ b/test/language/statements/class/async-gen-method-static-yield-promise-reject-next.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-promise-reject-next-catch.js b/test/language/statements/class/async-gen-method-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..4bbb1afabf --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-promise-reject-next-catch.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/statements/class/async-gen-method-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..c1373fd9c3 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/statements/class/async-gen-method-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..bf30ba112a --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/statements/class/async-gen-method-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..b4d12f15e8 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/statements/class/async-gen-method-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..2fe6c78986 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/async-gen-method-yield-promise-reject-next.js b/test/language/statements/class/async-gen-method-yield-promise-reject-next.js new file mode 100644 index 0000000000..d49d52b736 --- /dev/null +++ b/test/language/statements/class/async-gen-method-yield-promise-reject-next.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1);