Debian Codegraph @

js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-reject.js

raw
1 // |reftest| async
2 // Copyright (C) 2019 Leo Balter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-promise.allsettled
7 description: >
8 Error when advancing the provided iterable (rejecting promise)
9 info: |
10 Promise.allSettled ( iterable )
11
12 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
13 7. If result is an abrupt completion, then
14 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
15 b. IfAbruptRejectPromise(result, promiseCapability).
16
17 Runtime Semantics: PerformPromiseAllSettled
18
19 6. Repeat
20 a. Let next be IteratorStep(iteratorRecord).
21 b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
22 c. ReturnIfAbrupt(next).
23 features: [Promise.allSettled, Symbol.iterator]
24 flags: [async]
25 ---*/
26
27 var iterStepThrows = {};
28 var poisonedDone = {};
29 var error = new Test262Error();
30 Object.defineProperty(poisonedDone, 'done', {
31 get() {
32 throw error;
33 }
34 });
35 Object.defineProperty(poisonedDone, 'value', {
36 get() {
37 $DONE('The `value` property should not be accessed.');
38 }
39 });
40
41 iterStepThrows[Symbol.iterator] = function() {
42 return {
43 next() {
44 return poisonedDone;
45 }
46 };
47 };
48
49 Promise.allSettled(iterStepThrows).then(function() {
50 $DONE('The promise should be rejected.');
51 }, function(reason) {
52 assert.sameValue(reason, error);
53 }).then($DONE, $DONE);