summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Iterator/prototype/forEach/next-method-returns-throwing-value.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Iterator/prototype/forEach/next-method-returns-throwing-value.js')
-rw-r--r--js/src/tests/test262/built-ins/Iterator/prototype/forEach/next-method-returns-throwing-value.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Iterator/prototype/forEach/next-method-returns-throwing-value.js b/js/src/tests/test262/built-ins/Iterator/prototype/forEach/next-method-returns-throwing-value.js
new file mode 100644
index 0000000000..07d3061bdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Iterator/prototype/forEach/next-method-returns-throwing-value.js
@@ -0,0 +1,34 @@
+// |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.forEach
+description: >
+ Underlying iterator next returns object with throwing value getter
+info: |
+ %Iterator.prototype%.forEach ( fn )
+
+features: [iterator-helpers]
+flags: []
+---*/
+class ThrowingIterator extends Iterator {
+ next() {
+ return {
+ done: false,
+ get value() {
+ throw new Test262Error();
+ },
+ };
+ }
+ return() {
+ throw new Error();
+ }
+}
+
+let iterator = new ThrowingIterator();
+
+assert.throws(Test262Error, function () {
+ iterator.forEach(() => {});
+});
+
+reportCompare(0, 0);