From 7882fbfae3f927911368c8b1d17ea8e4c022c816 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Wed, 21 Feb 2018 17:30:47 -0500 Subject: async-iteration: move existing throw/return tests to AsyncGeneratorPrototype dir --- .../return/return-suspendedStart-promise.js | 50 ++++++++++++++++++ .../return/return-suspendedStart.js | 42 +++++++++++++++ .../return/return-suspendedYield-promise.js | 56 ++++++++++++++++++++ .../return-suspendedYield-try-finally-return.js | 55 +++++++++++++++++++ .../return-suspendedYield-try-finally-throw.js | 57 ++++++++++++++++++++ .../return/return-suspendedYield-try-finally.js | 61 ++++++++++++++++++++++ .../return/return-suspendedYield.js | 51 ++++++++++++++++++ .../throw/throw-suspendedStart-promise.js | 45 ++++++++++++++++ .../throw/throw-suspendedStart.js | 42 +++++++++++++++ .../throw/throw-suspendedYield-promise.js | 53 +++++++++++++++++++ .../throw/throw-suspendedYield-try-catch.js | 57 ++++++++++++++++++++ .../throw-suspendedYield-try-finally-return.js | 57 ++++++++++++++++++++ .../throw-suspendedYield-try-finally-throw.js | 57 ++++++++++++++++++++ .../throw/throw-suspendedYield-try-finally.js | 61 ++++++++++++++++++++++ .../throw/throw-suspendedYield.js | 50 ++++++++++++++++++ .../return-suspendedStart-promise.js | 50 ------------------ .../async-generator/return-suspendedStart.js | 42 --------------- .../return-suspendedYield-promise.js | 56 -------------------- .../return-suspendedYield-try-finally-return.js | 55 ------------------- .../return-suspendedYield-try-finally-throw.js | 57 -------------------- .../return-suspendedYield-try-finally.js | 61 ---------------------- .../async-generator/return-suspendedYield.js | 51 ------------------ .../throw-suspendedStart-promise.js | 45 ---------------- .../async-generator/throw-suspendedStart.js | 42 --------------- .../throw-suspendedYield-promise.js | 53 ------------------- .../throw-suspendedYield-try-catch.js | 57 -------------------- .../throw-suspendedYield-try-finally-return.js | 57 -------------------- .../throw-suspendedYield-try-finally-throw.js | 57 -------------------- .../throw-suspendedYield-try-finally.js | 61 ---------------------- .../async-generator/throw-suspendedYield.js | 50 ------------------ 30 files changed, 794 insertions(+), 794 deletions(-) create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-promise.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-return.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-throw.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart-promise.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-promise.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-return.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally.js create mode 100644 test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield.js delete mode 100644 test/language/expressions/async-generator/return-suspendedStart-promise.js delete mode 100644 test/language/expressions/async-generator/return-suspendedStart.js delete mode 100644 test/language/expressions/async-generator/return-suspendedYield-promise.js delete mode 100644 test/language/expressions/async-generator/return-suspendedYield-try-finally-return.js delete mode 100644 test/language/expressions/async-generator/return-suspendedYield-try-finally-throw.js delete mode 100644 test/language/expressions/async-generator/return-suspendedYield-try-finally.js delete mode 100644 test/language/expressions/async-generator/return-suspendedYield.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedStart-promise.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedStart.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedYield-promise.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedYield-try-catch.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedYield-try-finally-return.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedYield-try-finally-throw.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedYield-try-finally.js delete mode 100644 test/language/expressions/async-generator/throw-suspendedYield.js diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-promise.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-promise.js new file mode 100644 index 000000000..8556d7fd3 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-promise.js @@ -0,0 +1,50 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Generator is not resumed after a return type completion. + Returning promise before start +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedStart", generator is closed without being resumed. + + AsyncGeneratorResolve will unwrap Promise values (steps 6-10) +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +var resolve; +var promise = new Promise(function(resolver) { + resolve = resolver; +}); + +it.return(promise).then(function(ret) { + assert.sameValue(ret.value, 'unwrapped-value', 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); +}).catch($DONE); + +resolve('unwrapped-value'); diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart.js new file mode 100644 index 000000000..f54041c8b --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart.js @@ -0,0 +1,42 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Generator is not resumed after a return type completion. + Returning non-promise before start +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedStart", generator is closed without being resumed. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +it.return('sent-value').then(function(ret) { + assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js new file mode 100644 index 000000000..5387e5444 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-promise.js @@ -0,0 +1,56 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Generator is not resumed after a return type completion. + Returning promise +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedYield", generator is resumed and immediately closes the generator + and returns completion. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + yield 1; + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +var resolve; +var promise = new Promise(function(resolver) { + resolve = resolver; +}); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.return(promise).then(function(ret) { + assert.sameValue(ret.value, 'unwrapped-value', 'AsyncGeneratorResolve(generator, resultValue, true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + + resolve('unwrapped-value'); +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-return.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-return.js new file mode 100644 index 000000000..48052d139 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-return.js @@ -0,0 +1,55 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Returned generator suspended in a yield position resumes execution within + an associated finally +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated finally block, resume execution within finally. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in finally block.'); + } finally { + return 'done'; + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.return('sent-value').then(function(ret) { + assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-throw.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-throw.js new file mode 100644 index 000000000..493f65605 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally-throw.js @@ -0,0 +1,57 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Returned generator suspended in a yield position resumes execution + within an associated finally, capturing a new abrupt completion and + does not resume again within that finally block. +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated finally block, resume execution within finally. +flags: [async] +features: [async-iteration] +---*/ + +var error = new Error("boop"); +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in finally block.'); + } finally { + throw error; + throw new Test262Error('Generator must not be resumed.'); + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.return('sent-value').then($DONE, function(err) { + assert.sameValue(err, error, 'AsyncGeneratorReject(generator, resultValue)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally.js new file mode 100644 index 000000000..3660358e3 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-try-finally.js @@ -0,0 +1,61 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Returned generator suspended in a yield position resumes execution within + an associated finally. +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated finally block, resume execution within finally. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in finally block.'); + } finally { + yield 2; + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.return('sent-value').then(function(ret) { + assert.sameValue(ret.value, 2, 'Yield in finally block'); + assert.sameValue(ret.done, false, 'Yield in finally block'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, resultValue, true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield.js b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield.js new file mode 100644 index 000000000..21aca35e6 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield.js @@ -0,0 +1,51 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-return +description: > + Returned generator suspended in a yield position does not resume execution + without an associated finally. +info: | + AsyncGenerator.prototype.return ( value ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is + "suspendedYield", generator is resumed and immediately closes the generator + and returns completion. +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + yield 1; + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.return('sent-value').then(function(ret) { + assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, resultValue, true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart-promise.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart-promise.js new file mode 100644 index 000000000..06fccf685 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart-promise.js @@ -0,0 +1,45 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Generator is not resumed after a throw completion with a promise arg before + start +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedStart", generator is closed without being resumed. + + AsyncGeneratorReject will not unwrap Promise values +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +var promise = new Promise(function() {}); + +it.throw(promise).then($DONE, function(err) { + assert.sameValue(err, promise, 'AsyncGeneratorReject(generator, completion.[[Value]])'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart.js new file mode 100644 index 000000000..ef8abdf55 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedStart.js @@ -0,0 +1,42 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Generator is not resumed after a throw completion with a non-promise arg + before start +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedStart", generator is closed without being resumed. +flags: [async] +features: [async-iteration] +---*/ + +var error = new Error('boop'); +var g = async function*() { + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +it.throw(error).then($DONE, function(err) { + assert.sameValue(err, error, 'AsyncGeneratorReject(generator, completion.[[Value]])'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-promise.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-promise.js new file mode 100644 index 000000000..3948ed65d --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-promise.js @@ -0,0 +1,53 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Generator is not resumed after a throw completion with a promise arg +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedYield", generator is resumed and immediately and + closes the generator and returns completion. + + AsyncGeneratorReject will not unwrap Promise values +flags: [async] +features: [async-iteration] +---*/ + +var g = async function*() { + yield 1; + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +var promise = new Promise(function() {}); + +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.throw(promise).then($DONE, function(err) { + assert.sameValue(err, promise, 'AsyncGeneratorReject(generator, resultValue)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js new file mode 100644 index 000000000..dad975f7a --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js @@ -0,0 +1,57 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Thrown generator suspended in a yield position resumes execution within + the associated catch-block +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated catch block, resume execution within catch-block. +flags: [async] +features: [async-iteration] +---*/ + +var error = new Error('boop'); +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in catch block.'); + } catch (err) { + assert.sameValue(err, error); + return 'done'; + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.throw(error).then(function(ret) { + assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-return.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-return.js new file mode 100644 index 000000000..281aee5d6 --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-return.js @@ -0,0 +1,57 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Thrown generator suspended in a yield position resumes execution within + the associated finally block, returns and suspends execution again. +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated finally block, resume execution within finally. +flags: [async] +features: [async-iteration] +---*/ + +class Err extends Error {}; +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in finally block.'); + } finally { + return 'done'; + throw new Test262Error('Generator must not be resumed.'); + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.throw(new Err).then(function(ret) { + assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)'); + assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js new file mode 100644 index 000000000..15088f8ff --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js @@ -0,0 +1,57 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Thrown generator suspended in a yield position resumes execution within + the associated finally block and throws an error and suspendeds execution + again +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated finally block, resume execution within finally. +flags: [async] +features: [async-iteration] +---*/ + +var error = new Error('boop'); +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in finally block.'); + } finally { + throw error; + throw new Test262Error('Generator must not be resumed.'); + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.throw(new Error('superceded')).then($DONE, function(err) { + assert.sameValue(err, error, 'AsyncGeneratorReject(generator, resultValue)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally.js new file mode 100644 index 000000000..3ec534a3a --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally.js @@ -0,0 +1,61 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Thrown generator suspended in a yield position resumes execution within + the associated finally block. +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedYield", and generator is resumed within a try-block with an + associated finally block, resume execution within finally. +flags: [async] +features: [async-iteration] +---*/ + +var error = new Error('boop'); +var g = async function*() { + try { + yield 1; + throw new Test262Error('Generator must be resumed in finally block.'); + } finally { + yield 2; + } +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.throw(error).then(function(ret) { + assert.sameValue(ret.value, 2, 'Yield in finally block'); + assert.sameValue(ret.done, false, 'Yield in finally block'); + + it.next().then($DONE, function(err) { + assert.sameValue(err, error, 'AsyncGeneratorReject(generator, returnValue)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield.js b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield.js new file mode 100644 index 000000000..b413285bc --- /dev/null +++ b/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield.js @@ -0,0 +1,50 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Caitlin Potter +esid: sec-asyncgenerator-prototype-throw +description: > + Generator is not resumed after a throw completion with an error object +info: | + AsyncGenerator.prototype.throw ( exception ) + 1. Let generator be the this value. + 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. + 3. Return ! AsyncGeneratorEnqueue(generator, completion). + + AsyncGeneratorEnqueue ( generator, completion ) + ... + 8. If state is not "executing", then + a. Perform ! AsyncGeneratorResumeNext(generator). + ... + + AsyncGeneratorResumeNext: + If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is + "suspendedYield", generator is resumed and immediately and + closes the generator and returns completion. +flags: [async] +features: [async-iteration] +---*/ + +var error = new Error('boop'); +var g = async function*() { + yield 1; + throw new Test262Error('Generator must not be resumed.'); +}; + +var it = g(); +it.next().then(function(ret) { + assert.sameValue(ret.value, 1, 'Initial yield'); + assert.sameValue(ret.done, false, 'Initial yield'); + + it.throw(error).then($DONE, function(err) { + assert.sameValue(err, error, 'AsyncGeneratorReject(generator, resultValue)'); + + it.next().then(function(ret) { + assert.sameValue(ret.value, undefined, 'Generator is closed'); + assert.sameValue(ret.done, true, 'Generator is closed'); + }).then($DONE, $DONE); + + }).catch($DONE); + +}).catch($DONE); diff --git a/test/language/expressions/async-generator/return-suspendedStart-promise.js b/test/language/expressions/async-generator/return-suspendedStart-promise.js deleted file mode 100644 index 8556d7fd3..000000000 --- a/test/language/expressions/async-generator/return-suspendedStart-promise.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Generator is not resumed after a return type completion. - Returning promise before start -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedStart", generator is closed without being resumed. - - AsyncGeneratorResolve will unwrap Promise values (steps 6-10) -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -var resolve; -var promise = new Promise(function(resolver) { - resolve = resolver; -}); - -it.return(promise).then(function(ret) { - assert.sameValue(ret.value, 'unwrapped-value', 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); -}).catch($DONE); - -resolve('unwrapped-value'); diff --git a/test/language/expressions/async-generator/return-suspendedStart.js b/test/language/expressions/async-generator/return-suspendedStart.js deleted file mode 100644 index f54041c8b..000000000 --- a/test/language/expressions/async-generator/return-suspendedStart.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Generator is not resumed after a return type completion. - Returning non-promise before start -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedStart", generator is closed without being resumed. -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -it.return('sent-value').then(function(ret) { - assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, completion.[[Value]], true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); -}).catch($DONE); diff --git a/test/language/expressions/async-generator/return-suspendedYield-promise.js b/test/language/expressions/async-generator/return-suspendedYield-promise.js deleted file mode 100644 index 5387e5444..000000000 --- a/test/language/expressions/async-generator/return-suspendedYield-promise.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Generator is not resumed after a return type completion. - Returning promise -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedYield", generator is resumed and immediately closes the generator - and returns completion. -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - yield 1; - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -var resolve; -var promise = new Promise(function(resolver) { - resolve = resolver; -}); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.return(promise).then(function(ret) { - assert.sameValue(ret.value, 'unwrapped-value', 'AsyncGeneratorResolve(generator, resultValue, true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - - resolve('unwrapped-value'); -}).catch($DONE); diff --git a/test/language/expressions/async-generator/return-suspendedYield-try-finally-return.js b/test/language/expressions/async-generator/return-suspendedYield-try-finally-return.js deleted file mode 100644 index 48052d139..000000000 --- a/test/language/expressions/async-generator/return-suspendedYield-try-finally-return.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Returned generator suspended in a yield position resumes execution within - an associated finally -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated finally block, resume execution within finally. -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in finally block.'); - } finally { - return 'done'; - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.return('sent-value').then(function(ret) { - assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/return-suspendedYield-try-finally-throw.js b/test/language/expressions/async-generator/return-suspendedYield-try-finally-throw.js deleted file mode 100644 index 493f65605..000000000 --- a/test/language/expressions/async-generator/return-suspendedYield-try-finally-throw.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Returned generator suspended in a yield position resumes execution - within an associated finally, capturing a new abrupt completion and - does not resume again within that finally block. -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated finally block, resume execution within finally. -flags: [async] -features: [async-iteration] ----*/ - -var error = new Error("boop"); -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in finally block.'); - } finally { - throw error; - throw new Test262Error('Generator must not be resumed.'); - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.return('sent-value').then($DONE, function(err) { - assert.sameValue(err, error, 'AsyncGeneratorReject(generator, resultValue)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/return-suspendedYield-try-finally.js b/test/language/expressions/async-generator/return-suspendedYield-try-finally.js deleted file mode 100644 index 3660358e3..000000000 --- a/test/language/expressions/async-generator/return-suspendedYield-try-finally.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Returned generator suspended in a yield position resumes execution within - an associated finally. -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated finally block, resume execution within finally. -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in finally block.'); - } finally { - yield 2; - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.return('sent-value').then(function(ret) { - assert.sameValue(ret.value, 2, 'Yield in finally block'); - assert.sameValue(ret.done, false, 'Yield in finally block'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, resultValue, true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/return-suspendedYield.js b/test/language/expressions/async-generator/return-suspendedYield.js deleted file mode 100644 index 21aca35e6..000000000 --- a/test/language/expressions/async-generator/return-suspendedYield.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-return -description: > - Returned generator suspended in a yield position does not resume execution - without an associated finally. -info: | - AsyncGenerator.prototype.return ( value ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is return, and generator.[[AsyncGeneratorState]] is - "suspendedYield", generator is resumed and immediately closes the generator - and returns completion. -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - yield 1; - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.return('sent-value').then(function(ret) { - assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, resultValue, true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedStart-promise.js b/test/language/expressions/async-generator/throw-suspendedStart-promise.js deleted file mode 100644 index 06fccf685..000000000 --- a/test/language/expressions/async-generator/throw-suspendedStart-promise.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Generator is not resumed after a throw completion with a promise arg before - start -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedStart", generator is closed without being resumed. - - AsyncGeneratorReject will not unwrap Promise values -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -var promise = new Promise(function() {}); - -it.throw(promise).then($DONE, function(err) { - assert.sameValue(err, promise, 'AsyncGeneratorReject(generator, completion.[[Value]])'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedStart.js b/test/language/expressions/async-generator/throw-suspendedStart.js deleted file mode 100644 index ef8abdf55..000000000 --- a/test/language/expressions/async-generator/throw-suspendedStart.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Generator is not resumed after a throw completion with a non-promise arg - before start -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedStart", generator is closed without being resumed. -flags: [async] -features: [async-iteration] ----*/ - -var error = new Error('boop'); -var g = async function*() { - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -it.throw(error).then($DONE, function(err) { - assert.sameValue(err, error, 'AsyncGeneratorReject(generator, completion.[[Value]])'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedYield-promise.js b/test/language/expressions/async-generator/throw-suspendedYield-promise.js deleted file mode 100644 index 3948ed65d..000000000 --- a/test/language/expressions/async-generator/throw-suspendedYield-promise.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Generator is not resumed after a throw completion with a promise arg -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedYield", generator is resumed and immediately and - closes the generator and returns completion. - - AsyncGeneratorReject will not unwrap Promise values -flags: [async] -features: [async-iteration] ----*/ - -var g = async function*() { - yield 1; - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -var promise = new Promise(function() {}); - -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.throw(promise).then($DONE, function(err) { - assert.sameValue(err, promise, 'AsyncGeneratorReject(generator, resultValue)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedYield-try-catch.js b/test/language/expressions/async-generator/throw-suspendedYield-try-catch.js deleted file mode 100644 index dad975f7a..000000000 --- a/test/language/expressions/async-generator/throw-suspendedYield-try-catch.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Thrown generator suspended in a yield position resumes execution within - the associated catch-block -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated catch block, resume execution within catch-block. -flags: [async] -features: [async-iteration] ----*/ - -var error = new Error('boop'); -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in catch block.'); - } catch (err) { - assert.sameValue(err, error); - return 'done'; - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.throw(error).then(function(ret) { - assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedYield-try-finally-return.js b/test/language/expressions/async-generator/throw-suspendedYield-try-finally-return.js deleted file mode 100644 index 281aee5d6..000000000 --- a/test/language/expressions/async-generator/throw-suspendedYield-try-finally-return.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Thrown generator suspended in a yield position resumes execution within - the associated finally block, returns and suspends execution again. -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated finally block, resume execution within finally. -flags: [async] -features: [async-iteration] ----*/ - -class Err extends Error {}; -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in finally block.'); - } finally { - return 'done'; - throw new Test262Error('Generator must not be resumed.'); - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.throw(new Err).then(function(ret) { - assert.sameValue(ret.value, 'done', 'AsyncGeneratorResolve(generator, resultValue, true)'); - assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedYield-try-finally-throw.js b/test/language/expressions/async-generator/throw-suspendedYield-try-finally-throw.js deleted file mode 100644 index 15088f8ff..000000000 --- a/test/language/expressions/async-generator/throw-suspendedYield-try-finally-throw.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Thrown generator suspended in a yield position resumes execution within - the associated finally block and throws an error and suspendeds execution - again -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated finally block, resume execution within finally. -flags: [async] -features: [async-iteration] ----*/ - -var error = new Error('boop'); -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in finally block.'); - } finally { - throw error; - throw new Test262Error('Generator must not be resumed.'); - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.throw(new Error('superceded')).then($DONE, function(err) { - assert.sameValue(err, error, 'AsyncGeneratorReject(generator, resultValue)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedYield-try-finally.js b/test/language/expressions/async-generator/throw-suspendedYield-try-finally.js deleted file mode 100644 index 3ec534a3a..000000000 --- a/test/language/expressions/async-generator/throw-suspendedYield-try-finally.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Thrown generator suspended in a yield position resumes execution within - the associated finally block. -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedYield", and generator is resumed within a try-block with an - associated finally block, resume execution within finally. -flags: [async] -features: [async-iteration] ----*/ - -var error = new Error('boop'); -var g = async function*() { - try { - yield 1; - throw new Test262Error('Generator must be resumed in finally block.'); - } finally { - yield 2; - } -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.throw(error).then(function(ret) { - assert.sameValue(ret.value, 2, 'Yield in finally block'); - assert.sameValue(ret.done, false, 'Yield in finally block'); - - it.next().then($DONE, function(err) { - assert.sameValue(err, error, 'AsyncGeneratorReject(generator, returnValue)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - - }).catch($DONE); - -}).catch($DONE); diff --git a/test/language/expressions/async-generator/throw-suspendedYield.js b/test/language/expressions/async-generator/throw-suspendedYield.js deleted file mode 100644 index b413285bc..000000000 --- a/test/language/expressions/async-generator/throw-suspendedYield.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -author: Caitlin Potter -esid: sec-asyncgenerator-prototype-throw -description: > - Generator is not resumed after a throw completion with an error object -info: | - AsyncGenerator.prototype.throw ( exception ) - 1. Let generator be the this value. - 2. Let completion be Completion{[[Type]]: throw, [[Value]]: exception, [[Target]]: empty}. - 3. Return ! AsyncGeneratorEnqueue(generator, completion). - - AsyncGeneratorEnqueue ( generator, completion ) - ... - 8. If state is not "executing", then - a. Perform ! AsyncGeneratorResumeNext(generator). - ... - - AsyncGeneratorResumeNext: - If completion.[[Type]] is throw, and generator.[[AsyncGeneratorState]] is - "suspendedYield", generator is resumed and immediately and - closes the generator and returns completion. -flags: [async] -features: [async-iteration] ----*/ - -var error = new Error('boop'); -var g = async function*() { - yield 1; - throw new Test262Error('Generator must not be resumed.'); -}; - -var it = g(); -it.next().then(function(ret) { - assert.sameValue(ret.value, 1, 'Initial yield'); - assert.sameValue(ret.done, false, 'Initial yield'); - - it.throw(error).then($DONE, function(err) { - assert.sameValue(err, error, 'AsyncGeneratorReject(generator, resultValue)'); - - it.next().then(function(ret) { - assert.sameValue(ret.value, undefined, 'Generator is closed'); - assert.sameValue(ret.done, true, 'Generator is closed'); - }).then($DONE, $DONE); - - }).catch($DONE); - -}).catch($DONE); -- cgit v1.2.1