summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/from/modify-throw.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/non262/Iterator/from/modify-throw.js')
-rw-r--r--js/src/tests/non262/Iterator/from/modify-throw.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/from/modify-throw.js b/js/src/tests/non262/Iterator/from/modify-throw.js
new file mode 100644
index 0000000000..0db7cf6f61
--- /dev/null
+++ b/js/src/tests/non262/Iterator/from/modify-throw.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally
+const iter = {
+ next: () => ({ done: false, value: 0 }),
+ throw: (value) => ({ done: true, value }),
+};
+
+const wrap = Iterator.from(iter);
+
+let {done, value} = wrap.throw(0);
+assertEq(done, true);
+assertEq(value, 0);
+
+class TestError extends Error {}
+iter.throw = () => { throw new TestError(); };
+assertThrowsInstanceOf(() => wrap.throw(), TestError);
+
+if (typeof reportCompare === 'function')
+ reportCompare(0, 0);