Debian Codegraph @

js/src/tests/test262/built-ins/Promise/any/invoke-then-get-error-reject.js

raw
1 // |reftest| async
2 // Copyright (C) 2019 Leo Balter, 2020 Rick Waldron. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6 Error thrown when accessing the instance's `then` method (rejecting Promise)
7 esid: sec-promise.any
8 info: |
9 5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
10 6. If result is an abrupt completion, then
11 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
12 b. IfAbruptRejectPromise(result, promiseCapability).
13
14 Runtime Semantics: PerformPromiseAny
15
16 r. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], rejectElement »).
17
18 flags: [async]
19 features: [Promise.any, arrow-function]
20 ---*/
21 let error = new Test262Error();
22 let promise = Promise.resolve();
23
24 Object.defineProperty(promise, 'then', {
25 get() {
26 throw error;
27 }
28 });
29
30 Promise.any([promise]).then(() => {
31 $DONE('The promise should be rejected, but was resolved');
32 }, (reason) => {
33 assert.sameValue(reason, error);
34 }).then($DONE, $DONE);