summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/groupBy/groupLength.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/groupBy/groupLength.js')
-rw-r--r--js/src/tests/test262/built-ins/Object/groupBy/groupLength.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/groupBy/groupLength.js b/js/src/tests/test262/built-ins/Object/groupBy/groupLength.js
new file mode 100644
index 0000000000..2ab88b9a0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/groupBy/groupLength.js
@@ -0,0 +1,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);