summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/groupBy/invalid-property-key.js
blob: badc3b9137a46a147218b479250351c7225ec835 (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
// 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 errors when callback return value cannot be converted to a property key.
info: |
  Object.groupBy ( items, callbackfn )

  ...
  GroupBy ( items, callbackfn, coercion )

  6. Repeat,
    g. If coercion is property, then
      i. Set key to Completion(ToPropertyKey(key)).
      ii. IfAbruptCloseIterator(key, iteratorRecord).

  ...
features: [array-grouping]
---*/

assert.throws(Test262Error, function () {
  const array = [1];
  Object.groupBy(array, function () {
    return {
      toString() {
        throw new Test262Error('not a property key');
      }
    };
  })
});

reportCompare(0, 0);