1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator'))
//
//
/*---
esid: pending
description: Lazy %AsyncIterator.prototype% methods don't close the iterator if executor of Promise returned by `.next` throws.
info: >
AsyncIterator Helpers proposal 2.1.6
features: [iterator-helpers]
---*/
class TestError extends Error {}
class TestIterator extends AsyncIterator {
next() {
return new Promise((resolve, reject) => {
throw new TestError();
});
}
closed = false;
async return(value) {
this.closed = true;
return {done: true, value};
}
}
const methods = [
["map", x => x],
["filter", x => true],
["take", Infinity],
["drop", 0],
["asIndexedPairs", undefined],
["flatMap", async function*(x) { yield x; }],
];
(async () => {
for (const [method, arg] of methods) {
const iterator = new TestIterator();
assertEq(iterator.closed, false);
try {
await iterator[method](arg).next();
assertEq(true, false, 'Expected exception');
} catch(err) {
assertEq(err instanceof TestError, true);
}
assertEq(iterator.closed, false);
}
})();
if (typeof reportCompare == 'function')
reportCompare(0, 0);
|