Debian Codegraph @

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