Debian Codegraph @

js/src/tests/test262/built-ins/Promise/any/iter-arg-is-empty-string-reject.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 /*---
6 esid: sec-promise.any
7 description: >
8 Promise.any('') rejects with AggregateError, empty errors array.
9 info: |
10 Runtime Semantics: PerformPromiseAny ( iteratorRecord, constructor, resultCapability )
11
12 ...
13 3. Let errors be a new empty List.
14 ...
15 8. Repeat,
16 a. Let next be IteratorStep(iteratorRecord).
17 b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
18 c. ReturnIfAbrupt(next).
19 d. If next is false, then
20 i. Set iteratorRecord.[[Done]] to true.
21 ii. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
22 iii. If remainingElementsCount.[[Value]] is 0, then
23 1. Let error be a newly created AggregateError object.
24 2. Set error.[[AggregateErrors]] to errors.
25 3. Return ThrowCompletion(error).
26 ...
27
28 features: [AggregateError, Promise.any, arrow-function]
29 flags: [async]
30 ---*/
31
32 Promise.any('')
33 .then(
34 () => $DONE('The promise should be rejected, but was resolved'),
35 error => {
36 assert.sameValue(Object.getPrototypeOf(error), AggregateError.prototype);
37 assert(error instanceof AggregateError);
38 assert.sameValue(error.errors.length, 0);
39 }
40 ).then($DONE, $DONE);