diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js')
-rw-r--r-- | js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js b/js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js new file mode 100644 index 0000000000..88a48ae919 --- /dev/null +++ b/js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/throw-suspendedYield-try-catch.js @@ -0,0 +1,58 @@ +// |reftest| async +// 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 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); |