Debian Codegraph @

js/src/tests/test262/built-ins/Promise/any/reject-ignored-immed.js

raw
1 // |reftest| async
2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-promise.any
6 description: >
7 Resolved promises ignore rejections through immediate invocation of the
8 provided resolving function
9 info: |
10 Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
11
12 Runtime Semantics: PerformPromiseAny
13
14 ...
15 Let remainingElementsCount be a new Record { [[value]]: 1 }.
16 ...
17 8.d ...
18 ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
19 iii. If remainingElementsCount.[[value]] is 0,
20 1. Let error be a newly created AggregateError object.
21 2. Perform ! DefinePropertyOrThrow(error, "errors", Property Descriptor { [[Configurable]]: true, [[Enumerable]]: false, [[Writable]]: true, [[Value]]: errors }).
22 3. Return ThrowCompletion(error).
23 ...
24
25 Promise.any Reject Element Functions
26 ...
27 Let alreadyCalled be the value of F's [[AlreadyCalled]] internal slot.
28 If alreadyCalled.[[value]] is true, return undefined.
29 Set alreadyCalled.[[value]] to true.
30 ...
31
32 flags: [async]
33 features: [Promise.any, arrow-function]
34 ---*/
35
36 let fulfiller = {
37 then(resolve) {
38 resolve();
39 }
40 };
41 let lateRejector = {
42 then(resolve, reject) {
43 resolve();
44 reject();
45 }
46 };
47
48 Promise.any([fulfiller, lateRejector])
49 .then(() => {
50 $DONE();
51 }, () => {
52 $DONE('The promise should not be rejected.');
53 });