blob: d77789f04aa68aea233c374429593d7da429c060 (
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
|
// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally
class TestIterator extends Iterator {
constructor(value) {
super();
this.value = value;
}
next() {
return this.value;
}
}
const sum = (x, y) => x + y;
let iter = new TestIterator(undefined);
assertThrowsInstanceOf(() => iter.reduce(sum), TypeError);
iter = new TestIterator(null);
assertThrowsInstanceOf(() => iter.reduce(sum), TypeError);
iter = new TestIterator(0);
assertThrowsInstanceOf(() => iter.reduce(sum), TypeError);
iter = new TestIterator(false);
assertThrowsInstanceOf(() => iter.reduce(sum), TypeError);
iter = new TestIterator('');
assertThrowsInstanceOf(() => iter.reduce(sum), TypeError);
iter = new TestIterator(Symbol(''));
assertThrowsInstanceOf(() => iter.reduce(sum), TypeError);
if (typeof reportCompare === 'function')
reportCompare(0, 0);
|