tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

toPropertyKey.js (770B)


      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-map.groupby
      6 description: Map.groupBy does not coerce return value with ToPropertyKey
      7 info: |
      8  Map.groupBy ( items, callbackfn )
      9 
     10  ...
     11 includes: [compareArray.js]
     12 features: [array-grouping, Map]
     13 ---*/
     14 
     15 let calls = 0;
     16 const stringable = {
     17  toString: function toString() {
     18    return 1;
     19  }
     20 };
     21 
     22 const array = [1, '1', stringable];
     23 
     24 const map = Map.groupBy(array, function (v) { return v; });
     25 
     26 assert.compareArray(Array.from(map.keys()), [1, '1', stringable]);
     27 assert.compareArray(map.get('1'), ['1']);
     28 assert.compareArray(map.get(1), [1]);
     29 assert.compareArray(map.get(stringable), [stringable]);
     30 
     31 reportCompare(0, 0);