summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/prototype/lazy-methods-throw-eagerly-on-non-callable.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/Iterator/prototype/lazy-methods-throw-eagerly-on-non-callable.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/prototype/lazy-methods-throw-eagerly-on-non-callable.js b/js/src/tests/non262/Iterator/prototype/lazy-methods-throw-eagerly-on-non-callable.js
new file mode 100644
index 0000000000..7c31a21a38
--- /dev/null
+++ b/js/src/tests/non262/Iterator/prototype/lazy-methods-throw-eagerly-on-non-callable.js
@@ -0,0 +1,38 @@
+// |reftest| skip-if(!this.hasOwnProperty('Iterator'))
+
+//
+//
+/*---
+esid: pending
+description: Lazy %Iterator.prototype% methods throw eagerly when passed non-callables.
+info: >
+ Iterator Helpers proposal 2.1.5
+features: [iterator-helpers]
+---*/
+
+const methods = [
+ (iter, fn) => iter.map(fn),
+ (iter, fn) => iter.filter(fn),
+ (iter, fn) => iter.flatMap(fn),
+];
+
+for (const method of methods) {
+ assertThrowsInstanceOf(() => method(Iterator.prototype, 0), TypeError);
+ assertThrowsInstanceOf(() => method(Iterator.prototype, false), TypeError);
+ assertThrowsInstanceOf(() => method(Iterator.prototype, undefined), TypeError);
+ assertThrowsInstanceOf(() => method(Iterator.prototype, null), TypeError);
+ assertThrowsInstanceOf(() => method(Iterator.prototype, ''), TypeError);
+ assertThrowsInstanceOf(() => method(Iterator.prototype, Symbol('')), TypeError);
+ assertThrowsInstanceOf(() => method(Iterator.prototype, {}), TypeError);
+
+ assertThrowsInstanceOf(() => method([].values(), 0), TypeError);
+ assertThrowsInstanceOf(() => method([].values(), false), TypeError);
+ assertThrowsInstanceOf(() => method([].values(), undefined), TypeError);
+ assertThrowsInstanceOf(() => method([].values(), null), TypeError);
+ assertThrowsInstanceOf(() => method([].values(), ''), TypeError);
+ assertThrowsInstanceOf(() => method([].values(), Symbol('')), TypeError);
+ assertThrowsInstanceOf(() => method([].values(), {}), TypeError);
+}
+
+if (typeof reportCompare == 'function')
+ reportCompare(0, 0);