summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/groupBy/iterator-next-throws.js
blob: 01d981a0abbb2e99da414829f519889ceef936de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) 2023 Ecma International.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-object.groupby
description: Object.groupBy throws when iterator next throws
info: |
  Object.groupBy ( items, callbackfn )

  ...

  GroupBy ( items, callbackfn, coercion )

  6. Repeat,
    b. Let next be ? IteratorStep(iteratorRecord).

  ...
features: [array-grouping, Symbol.iterator]
---*/

const throwingIterator = {
  [Symbol.iterator]: function () {
    return this;
  },
  next: function next() {
    throw new Test262Error('next() method was called');
  }
};

assert.throws(Test262Error, function () {
  Object.groupBy(throwingIterator, function () {
    return 'key';
  });
});

reportCompare(0, 0);