Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/iter-step-err-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 /*---
5 esid: sec-promise.all
6 es6id: 25.4.4.1
7 description: >
8 Error when advancing the provided iterable (not closing iterator)
9 info: |
10 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
11 12. If result is an abrupt completion,
12 a. If iteratorRecord.[[done]] is false, let result be
13 IteratorClose(iterator, result).
14 b. IfAbruptRejectPromise(result, promiseCapability).
15
16 [...]
17
18 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
19
20 [...]
21 6. Repeat
22 a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
23 b. If next is an abrupt completion, set iteratorRecord.[[done]] to
24 true.
25 c. ReturnIfAbrupt(next).
26 features: [Symbol.iterator]
27 ---*/
28
29 var iterStepThrows = {};
30 var poisonedDone = {};
31 var returnCount = 0;
32 var error = new Test262Error();
33 Object.defineProperty(poisonedDone, 'done', {
34 get: function() {
35 throw error;
36 }
37 });
38 Object.defineProperty(poisonedDone, 'value', {
39 get: function() {
40 $ERROR('The `value` property should not be accessed.');
41 }
42 });
43
44 iterStepThrows[Symbol.iterator] = function() {
45 return {
46 next: function() {
47 return poisonedDone;
48 },
49 return: function() {
50 returnCount += 1;
51 return {};
52 }
53 };
54 };
55
56 Promise.all(iterStepThrows);
57
58 assert.sameValue(returnCount, 0);