Fix Map hash bug

- `map_hash_key` must generate the same key for JS_INT and JS_FLOAT64
   with the same value
- add test cases in tests/test_builtin.js
This commit is contained in:
Charlie Gordon
2024-02-22 19:31:57 +01:00
parent b70e764427
commit 27928ce491
2 changed files with 16 additions and 2 deletions

View File

@@ -671,6 +671,20 @@ function test_map()
{
var a, i, n, tab, o, v;
n = 1000;
a = new Map();
for (var i = 0; i < n; i++) {
a.set(i, i);
}
a.set(-2147483648, 1);
assert(a.get(-2147483648), 1);
assert(a.get(-2147483647 - 1), 1);
assert(a.get(-2147483647.5 - 0.5), 1);
a.set(1n, 1n);
assert(a.get(1n), 1n);
assert(a.get(2n**1000n - (2n**1000n - 1n)), 1n);
a = new Map();
tab = [];
for(i = 0; i < n; i++) {