summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/prototype/forEach/next-throws-iterator-not-closed.js
blob: 042b6d660c6597d9a7400b9245b1a53293421d5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 fn = () => {};
const iter = new TestIterator();

assertEq(iter.closed, false);
assertThrowsInstanceOf(() => iter.forEach(fn), Error);
assertEq(iter.closed, false);

if (typeof reportCompare === 'function')
  reportCompare(0, 0);