summaryrefslogtreecommitdiff
path: root/test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js
diff options
context:
space:
mode:
authorValerie R Young <valerie@bocoup.com>2018-02-21 17:30:47 -0500
committerRick Waldron <waldron.rick@gmail.com>2018-02-22 13:34:08 -0500
commit7882fbfae3f927911368c8b1d17ea8e4c022c816 (patch)
treeba74bcceccb56fc25bdec43e695273485fecbd3e /test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js
parentd807e8fa96df23b7662ad900f87402d9d6125b69 (diff)
downloadqtdeclarative-testsuites-7882fbfae3f927911368c8b1d17ea8e4c022c816.tar.gz
async-iteration: move existing throw/return tests to AsyncGeneratorPrototype dir
Diffstat (limited to 'test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js')
-rw-r--r--test/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-finally-throw.js57
1 files changed, 57 insertions, 0 deletions
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 <caitp@igalia.com>
+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);