Debian Codegraph @

js/src/tests/test262/built-ins/Object/groupBy/emptyList.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: Callback is not called and object is not populated if the iterable is empty
7 info: |
8 Object.groupBy ( items, callbackfn )
9
10 ...
11 GroupBy ( items, callbackfn, coercion )
12
13 6. Repeat,
14 c. If next is false, then
15 i. Return groups.
16 ...
17 features: [array-grouping]
18 ---*/
19
20 const original = [];
21
22 const obj = Object.groupBy(original, function () {
23 throw new Test262Error('callback function should not be called')
24 });
25
26 assert.notSameValue(original, obj, 'Object.groupBy returns an object');
27 assert.sameValue(Object.keys(obj).length, 0);
28
29 reportCompare(0, 0);