summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-03-19 12:33:54 +0100
committerFabrice Bellard <fabrice@bellard.org>2025-03-19 12:33:54 +0100
commit6d6893bfa3d383d4952b67954003800aba1f4be8 (patch)
treef1125ee057b2e61a0c530b7b0973cb602b7771f2 /tests
parent5a16c0c1eba084742ed328eff75b9e886e63d166 (diff)
downloadquickjs-6d6893bfa3d383d4952b67954003800aba1f4be8.tar.gz
quickjs-6d6893bfa3d383d4952b67954003800aba1f4be8.zip
fixed BigInt hashing - removed -fno-bigint in qjsc and JS_AddIntrinsicBigInt() (BigInt is now considered as a base object)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_builtin.js56
1 files changed, 38 insertions, 18 deletions
diff --git a/tests/test_builtin.js b/tests/test_builtin.js
index 15cd189..1c47f8f 100644
--- a/tests/test_builtin.js
+++ b/tests/test_builtin.js
@@ -714,29 +714,26 @@ function test_symbol()
assert(b.toString(), "Symbol(aaa)");
}
-function test_map()
+function test_map1(key_type, n)
{
- 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);
-
+ var a, i, tab, o, v;
a = new Map();
tab = [];
for(i = 0; i < n; i++) {
v = { };
- o = { id: i };
+ switch(key_type) {
+ case "small_bigint":
+ o = BigInt(i);
+ break;
+ case "bigint":
+ o = BigInt(i) + (1n << 128n);
+ break;
+ case "object":
+ o = { id: i };
+ break;
+ default:
+ assert(false);
+ }
tab[i] = [o, v];
a.set(o, v);
}
@@ -757,6 +754,29 @@ function test_map()
assert(a.size, 0);
}
+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);
+
+ test_map1("object", n);
+ test_map1("small_bigint", n);
+ test_map1("bigint", n);
+}
+
function test_weak_map()
{
var a, i, n, tab, o, v, n2;