summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/prototype/reduce/next-throws-iterator-not-closed.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/non262/Iterator/prototype/reduce/next-throws-iterator-not-closed.js')
-rw-r--r--js/src/tests/non262/Iterator/prototype/reduce/next-throws-iterator-not-closed.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/prototype/reduce/next-throws-iterator-not-closed.js b/js/src/tests/non262/Iterator/prototype/reduce/next-throws-iterator-not-closed.js
new file mode 100644
index 0000000000..0fbeb995f1
--- /dev/null
+++ b/js/src/tests/non262/Iterator/prototype/reduce/next-throws-iterator-not-closed.js
@@ -0,0 +1,22 @@
+// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally
+
+class TestIterator extends Iterator {
+ next() {
+ throw new Error();
+ }
+
+ closed = false;
+ return() {
+ this.closed = true;
+ }
+}
+
+const sum = (x, y) => x + y;
+const iter = new TestIterator();
+
+assertEq(iter.closed, false);
+assertThrowsInstanceOf(() => iter.reduce(sum), Error);
+assertEq(iter.closed, false);
+
+if (typeof reportCompare === 'function')
+ reportCompare(0, 0);