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/this-val-not-async-generator.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/this-val-not-async-generator.js')
-rw-r--r-- | js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/this-val-not-async-generator.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/this-val-not-async-generator.js b/js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/this-val-not-async-generator.js new file mode 100644 index 0000000000..65ef63e8b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/AsyncGeneratorPrototype/throw/this-val-not-async-generator.js @@ -0,0 +1,90 @@ +// |reftest| async +// Copyright 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgenerator-prototype-throw +description: throw rejects promise when `this` value is not an async generator +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 ) + ... + 3. If Type(generator) is not Object, or if generator does not have an + [[AsyncGeneratorState]] internal slot, then + a. Let badGeneratorError be a newly created TypeError object. + b. Perform ! Call(promiseCapability.[[Reject]], undefined, « badGeneratorError »). + c. Return promiseCapability.[[Promise]]. + +flags: [async] +features: [async-iteration] +---*/ + +async function* g() {} +var AsyncGeneratorPrototype = Object.getPrototypeOf(g).prototype; + +function* syncGenerator() {} +var syncIterator = syncGenerator() + +var testPromises = [ + AsyncGeneratorPrototype.throw.call({}).then( + function () { + throw new Test262Error("AsyncGeneratorPrototype.throw should reject promise" + + " when `this` value is an object"); + }, + function (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("(object) expected TypeError but got " + e); + } + } + ), + AsyncGeneratorPrototype.throw.call(function() {}).then( + function () { + throw new Test262Error("AsyncGeneratorPrototype.throw should reject promise" + + " when `this` value is a function"); + }, + function (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("(function) expected TypeError but got " + e); + } + } + ), + AsyncGeneratorPrototype.throw.call(g).then( + function () { + throw new Test262Error("AsyncGeneratorPrototype.throw should reject promise" + + " when `this` value is an async generator function"); + }, + function (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("(async generator function) expected TypeError but got " + e); + } + } + ), + AsyncGeneratorPrototype.throw.call(g.prototype).then( + function () { + throw new Test262Error("AsyncGeneratorPrototype.throw should reject promise" + + " when `this` value is an async generator function prototype object"); + }, + function (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("(async generator function prototype) expected TypeError but got " + e); + } + }, + ), + AsyncGeneratorPrototype.throw.call(syncIterator).then( + function () { + throw new Test262Error("AsyncGeneratorPrototype.throw should reject promise" + + " when `this` value is a generator"); + }, + function (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("(generator) expected TypeError but got " + e); + } + } + ) +] + +Promise.all(testPromises).then(() => {}).then($DONE, $DONE) |