summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js')
-rw-r--r--js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js b/js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js
new file mode 100644
index 0000000000..c33e5e4f9c
--- /dev/null
+++ b/js/src/tests/non262/Iterator/prototype/reduce/reducer-not-callable-throws.js
@@ -0,0 +1,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);