summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js
blob: c33e5e4f9c34b335eee37e90caf09d18c0cc1d9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally

class TestIterator extends Iterator {
  next() {
    return { done: false, value: 0 };
  }
}

const iter = new TestIterator();
assertThrowsInstanceOf(() => iter.reduce(), TypeError);
assertThrowsInstanceOf(() => iter.reduce(undefined), TypeError);
assertThrowsInstanceOf(() => iter.reduce(null), TypeError);
assertThrowsInstanceOf(() => iter.reduce(0), TypeError);
assertThrowsInstanceOf(() => iter.reduce(false), TypeError);
assertThrowsInstanceOf(() => iter.reduce(''), TypeError);
assertThrowsInstanceOf(() => iter.reduce(Symbol('')), TypeError);
assertThrowsInstanceOf(() => iter.reduce({}), TypeError);

if (typeof reportCompare === 'function')
  reportCompare(0, 0);