summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-02-22 19:31:57 +0100
committerCharlie Gordon <github@chqrlie.org>2024-02-22 19:31:57 +0100
commit27928ce49170a17170bb01649fc27624c0494b05 (patch)
tree90d2bcad1795740479be5192e76a9ef5edac4612 /tests
parentb70e764427c885603b0285c8a64a218ae6361b1d (diff)
downloadquickjs-27928ce49170a17170bb01649fc27624c0494b05.tar.gz
quickjs-27928ce49170a17170bb01649fc27624c0494b05.zip
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
Diffstat (limited to 'tests')
-rw-r--r--tests/test_builtin.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_builtin.js b/tests/test_builtin.js
index f4fece8..22c5464 100644
--- a/tests/test_builtin.js
+++ b/tests/test_builtin.js
@@ -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++) {