summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Map/groupBy/string.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Map/groupBy/string.js')
-rw-r--r--js/src/tests/test262/built-ins/Map/groupBy/string.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Map/groupBy/string.js b/js/src/tests/test262/built-ins/Map/groupBy/string.js
new file mode 100644
index 0000000000..15a2410c5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/groupBy/string.js
@@ -0,0 +1,24 @@
+// 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 works for string items
+info: |
+ Map.groupBy ( items, callbackfn )
+ ...
+includes: [compareArray.js]
+features: [array-grouping, Map]
+---*/
+
+const string = '🥰💩🙏😈';
+
+const map = Map.groupBy(string, function (char) {
+ return char < '🙏' ? 'before' : 'after';
+});
+
+assert.compareArray(Array.from(map.keys()), ['after', 'before']);
+assert.compareArray(map.get('before'), ['💩', '😈']);
+assert.compareArray(map.get('after'), ['🥰', '🙏']);
+
+reportCompare(0, 0);