negativeZero.js (669B)
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 normalizes 0 for Map key 7 info: | 8 Map.groupBy ( items, callbackfn ) 9 10 ... 11 12 GroupBy ( items, callbackfn, coercion ) 13 14 6. Repeat, 15 h. Else, 16 i. Assert: coercion is zero. 17 ii. If key is -0𝔽, set key to +0𝔽. 18 19 ... 20 includes: [compareArray.js] 21 features: [array-grouping, Map] 22 ---*/ 23 24 25 const arr = [-0, +0]; 26 27 const map = Map.groupBy(arr, function (i) { return i; }); 28 29 assert.sameValue(map.size, 1); 30 assert.compareArray(map.get(0), [-0, 0]); 31 32 reportCompare(0, 0);