blob: 230ebb8fafa4e76c1354871197e0f362afa030b9 (
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
34
35
36
37
|
// |reftest| skip-if(!this.hasOwnProperty('Iterator'))
//
//
/*---
esid: pending
description: %Iterator.prototype%.drop returns if the iterator is done.
info: >
Iterator Helpers proposal 2.1.5.5
1. Repeat, while remaining > 0,
...
b. Let next be ? IteratorStep(iterated).
c. If next is false, return undefined.
features: [iterator-helpers]
---*/
let iter = [1, 2].values().drop(3);
let result = iter.next();
assertEq(result.value, undefined);
assertEq(result.done, true);
class TestIterator extends Iterator {
counter = 0;
next() {
return {done: ++this.counter >= 2, value: undefined};
}
}
iter = new TestIterator();
let dropped = iter.drop(10);
result = dropped.next();
assertEq(result.value, undefined);
assertEq(result.done, true);
assertEq(iter.counter, 2);
if (typeof reportCompare == 'function')
reportCompare(0, 0);
|