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