Debian Codegraph @

js/src/tests/test262/built-ins/Object/groupBy/iterator-next-throws.js

raw
1 // Copyright (c) 2023 Ecma International. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object.groupby
6 description: Object.groupBy throws when iterator next throws
7 info: |
8 Object.groupBy ( items, callbackfn )
9
10 ...
11
12 GroupBy ( items, callbackfn, coercion )
13
14 6. Repeat,
15 b. Let next be ? IteratorStep(iteratorRecord).
16
17 ...
18 features: [array-grouping, Symbol.iterator]
19 ---*/
20
21 const throwingIterator = {
22 [Symbol.iterator]: function () {
23 return this;
24 },
25 next: function next() {
26 throw new Test262Error('next() method was called');
27 }
28 };
29
30 assert.throws(Test262Error, function () {
31 Object.groupBy(throwingIterator, function () {
32 return 'key';
33 });
34 });
35
36 reportCompare(0, 0);