aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/tests
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/common/tests')
-rw-r--r--builtin/common/tests/serialize_spec.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/common/tests/serialize_spec.lua b/builtin/common/tests/serialize_spec.lua
index ea79680d7..340e226ee 100644
--- a/builtin/common/tests/serialize_spec.lua
+++ b/builtin/common/tests/serialize_spec.lua
@@ -133,7 +133,9 @@ describe("serialize", function()
end
local function num()
local sign = math.random() < 0.5 and -1 or 1
- local val = math.random(0, 2^52)
+ -- HACK math.random(a, b) requires a, b & b - a to fit within a 32-bit int
+ -- Use two random calls to generate a random number from 0 - 2^50 as lower & upper 25 bits
+ local val = math.random(0, 2^25) * 2^25 + math.random(0, 2^25 - 1)
local exp = math.random() < 0.5 and 1 or 2^(math.random(-120, 120))
return sign * val * exp
end
@@ -152,7 +154,7 @@ describe("serialize", function()
local root = {}
local tables = {root}
local function random_table()
- return tables[#tables == 1 and 1 or math.random(1, #tables)] -- luacheck: ignore
+ return tables[math.random(1, #tables)]
end
for _ = 1, math.random(1, max_actions) do
local tab = random_table()