summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/groupBy/groupLength.js
blob: 2ab88b9a0dc2dd15531292c8af271c6820c2fea5 (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
// 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: Callback can return numbers that are converted to property keys
info: |
  Object.groupBy ( items, callbackfn )

  ...
  GroupBy ( items, callbackfn, coercion )

  6. Repeat,
    c. If next is false, then
      i. Return groups.
  ...
includes: [compareArray.js]
features: [array-grouping]
---*/

const arr = ['hello', 'test', 'world'];

const obj = Object.groupBy(arr, function (i) { return i.length; });

assert.compareArray(Object.keys(obj), ['4', '5']);
assert.compareArray(obj['5'], ['hello', 'world']);
assert.compareArray(obj['4'], ['test']);

reportCompare(0, 0);