Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/iter-next-val-err-reject.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-promise.all
6 es6id: 25.4.4.1
7 description: >
8 Error when accessing an iterator result's `value` property (rejecting
9 promise)
10 info: |
11 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
12 12. If result is an abrupt completion,
13 a. If iteratorRecord.[[done]] is false, let result be
14 IteratorClose(iterator, result).
15 b. IfAbruptRejectPromise(result, promiseCapability).
16
17 [...]
18
19 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
20
21 [...]
22 6. Repeat
23 [...]
24 e. Let nextValue be IteratorValue(next).
25 f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
26 true.
27 g. ReturnIfAbrupt(nextValue).
28 features: [Symbol.iterator]
29 flags: [async]
30 ---*/
31
32 var iterNextValThrows = {};
33 var poisonedVal = {
34 done: false
35 };
36 var error = new Test262Error();
37 Object.defineProperty(poisonedVal, 'value', {
38 get: function() {
39 throw error;
40 }
41 });
42 iterNextValThrows[Symbol.iterator] = function() {
43 return {
44 next: function() {
45 return poisonedVal;
46 }
47 };
48 };
49
50 Promise.all(iterNextValThrows).then(function() {
51 $ERROR('The promise should be rejected.');
52 }, function(reason) {
53 assert.sameValue(reason, error);
54 }).then($DONE, $DONE);