blob: 8c61eee0598713bc2f2cdce2c642d5523c85933c (
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
38
39
40
41
42
43
44
45
|
function makeArrayIterator(array) {
let i = 0;
return {
[Symbol.iterator]() {
return {
next() {
if (i >= array.length) {
return { done: true };
} else {
return { value: array[i++] };
}
}
};
}
}
}
function makeArrayIteratorWithHasMethod(array) {
let i = 0;
return {
has(item) {
return array.includes(item);
},
[Symbol.iterator]() {
return {
next() {
if (i >= array.length) {
return { done: true };
} else {
return { value: array[i++] };
}
}
};
}
};
}
function assertSetContainsExactOrderedItems(actual, expected) {
assertEq(actual.size, expected.length);
let index = 0;
for (const item of actual) {
assertEq(item, expected[index]);
index++;
}
}
|