blob: 553e6934f7fb73f6fd065a3f92eab7e4fbdd36f7 (
plain)
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
|
// |reftest| skip-if(!this.hasOwnProperty('Iterator'))
class TestIterator extends Iterator {
next(value) {
return {done: false, value};
}
}
const methods = [
iter => iter.map(x => x),
iter => iter.filter(x => true),
iter => iter.take(2),
iter => iter.drop(0),
iter => iter.asIndexedPairs(),
];
for (const outerMethod of methods) {
for (const innerMethod of methods) {
const iterator = new TestIterator();
const iteratorChain = outerMethod(innerMethod(iterator));
iteratorChain.next();
let result = iteratorChain.next('last value');
assertEq(result.done, false);
// Unwrap the asIndexedPair return values.
while (Array.isArray(result.value)) {
result.value = result.value[1];
}
assertEq(result.value, 'last value');
}
}
if (typeof reportCompare == 'function')
reportCompare(0, 0);
|