diff options
Diffstat (limited to 'js/src/tests/non262/Iterator/prototype/reduce/iterator-next-return-non-object-throws.js')
-rw-r--r-- | js/src/tests/non262/Iterator/prototype/reduce/iterator-next-return-non-object-throws.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/prototype/reduce/iterator-next-return-non-object-throws.js b/js/src/tests/non262/Iterator/prototype/reduce/iterator-next-return-non-object-throws.js new file mode 100644 index 0000000000..d77789f04a --- /dev/null +++ b/js/src/tests/non262/Iterator/prototype/reduce/iterator-next-return-non-object-throws.js @@ -0,0 +1,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); |