From 1dc78879d40e7c8b66aac6da47269cf43b0f5d21 Mon Sep 17 00:00:00 2001 From: Caio Lima Date: Thu, 11 Jul 2019 16:33:37 -0300 Subject: [PATCH] Add edge tests to verify BigInt to Number conversion when BigInt can't directly be represented by a Number. --- test/built-ins/Number/bigint-conversion.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/built-ins/Number/bigint-conversion.js b/test/built-ins/Number/bigint-conversion.js index 12fe032295..0397fb0266 100644 --- a/test/built-ins/Number/bigint-conversion.js +++ b/test/built-ins/Number/bigint-conversion.js @@ -9,3 +9,15 @@ features: [BigInt] assert.sameValue(Number(0n), 0); assert.sameValue(+(new Number(0n)), +(new Number(0))); + +assert.sameValue(Number(2n**53n), 9007199254740992); +assert.sameValue(Number(2n**53n + 1n), 9007199254740992); +assert.sameValue(Number(2n**53n + 2n), 9007199254740994); +assert.sameValue(Number(2n**53n + 3n), 9007199254740996); +assert.sameValue(Number(2n**53n + 4n), 9007199254740996); + +assert.sameValue(Number(-(2n**53n)), -9007199254740992); +assert.sameValue(Number(-(2n**53n + 1n)), -9007199254740992); +assert.sameValue(Number(-(2n**53n + 2n)), -9007199254740994); +assert.sameValue(Number(-(2n**53n + 3n)), -9007199254740996); +assert.sameValue(Number(-(2n**53n + 4n)), -9007199254740996);