summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Map/groupBy/toPropertyKey.js
blob: 94f80a42b6f55968a2b7801eac6c514c58b6a55e (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
// Copyright (c) 2023 Ecma International.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-map.groupby
description: Map.groupBy does not coerce return value with ToPropertyKey
info: |
  Map.groupBy ( items, callbackfn )

  ...
includes: [compareArray.js]
features: [array-grouping, Map]
---*/

let calls = 0;
const stringable = {
  toString: function toString() {
    return 1;
  }
};

const array = [1, '1', stringable];

const map = Map.groupBy(array, function (v) { return v; });

assert.compareArray(Array.from(map.keys()), [1, '1', stringable]);
assert.compareArray(map.get('1'), ['1']);
assert.compareArray(map.get(1), [1]);
assert.compareArray(map.get(stringable), [stringable]);

reportCompare(0, 0);