summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Iterator/prototype/find/predicate-throws-then-closing-iterator-also-throws.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Iterator/prototype/find/predicate-throws-then-closing-iterator-also-throws.js')
-rw-r--r--js/src/tests/test262/built-ins/Iterator/prototype/find/predicate-throws-then-closing-iterator-also-throws.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Iterator/prototype/find/predicate-throws-then-closing-iterator-also-throws.js b/js/src/tests/test262/built-ins/Iterator/prototype/find/predicate-throws-then-closing-iterator-also-throws.js
new file mode 100644
index 0000000000..726d133268
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Iterator/prototype/find/predicate-throws-then-closing-iterator-also-throws.js
@@ -0,0 +1,39 @@
+// |reftest| shell-option(--enable-iterator-helpers) skip-if(!this.hasOwnProperty('Iterator')||!xulRuntime.shell) -- iterator-helpers is not enabled unconditionally, requires shell-options
+// Copyright (C) 2023 Michael Ficarra. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-iteratorprototype.find
+description: >
+ Attempts to close iterator when predicate throws, but that throws
+info: |
+ %Iterator.prototype%.find ( predicate )
+
+features: [iterator-helpers]
+flags: []
+---*/
+let returnCalls = 0;
+
+class TestIterator extends Iterator {
+ next() {
+ return {
+ done: false,
+ value: 1,
+ };
+ }
+ return() {
+ ++returnCalls;
+ throw new Error();
+ }
+}
+
+let iterator = new TestIterator();
+
+assert.throws(Test262Error, function () {
+ iterator.find(() => {
+ throw new Test262Error();
+ });
+});
+
+assert.sameValue(returnCalls, 1);
+
+reportCompare(0, 0);