Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/capability-resolve-throws-no-close.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-promise.all
5 es6id: 25.4.4.1
6 description: >
7 Iterator is not closed when the "resolve" capability returns an abrupt
8 completion.
9 info: |
10 1. Let C be the this value.
11 [...]
12 3. Let promiseCapability be ? NewPromiseCapability(C).
13 [...]
14 7. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
15 8. If result is an abrupt completion, then
16 a. If iteratorRecord.[[Done]] is false, let result be
17 IteratorClose(iterator, result).
18 b. IfAbruptRejectPromise(result, promiseCapability).
19
20 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
21
22 [...]
23 6. Repeat
24 [...]
25 d. If next is false, then
26 [...]
27 iii. If remainingElementsCount.[[Value]] is 0, then
28 1. Let valuesArray be CreateArrayFromList(values).
29 2. Perform ? Call(resultCapability.[[Resolve]], undefined, «
30 valuesArray »).
31
32 25.4.1.1.1 IfAbruptRejectPromise
33
34 IfAbruptRejectPromise is a short hand for a sequence of algorithm steps that
35 use a PromiseCapability Record. An algorithm step of the form:
36
37 1. IfAbruptRejectPromise(value, capability).
38
39 means the same thing as:
40
41 1. If value is an abrupt completion, then
42 a. Perform ? Call(capability.[[Reject]], undefined, « value.[[Value]] »).
43 b. Return capability.[[Promise]].
44 2. Else if value is a Completion Record, let value be value.[[Value]].
45 features: [Symbol.iterator]
46 ---*/
47
48 var returnCount = 0;
49 var iter = {};
50 iter[Symbol.iterator] = function() {
51 return {
52 next: function() {
53 return {
54 done: true
55 };
56 },
57 return: function() {
58 returnCount += 1;
59 return {};
60 }
61 };
62 };
63 var P = function(executor) {
64 return new Promise(function(_, reject) {
65 executor(function() {
66 throw new Test262Error();
67 }, reject);
68 });
69 };
70
71 Promise.all.call(P, iter);
72
73 assert.sameValue(returnCount, 0);