fixes #23915; std/random produces different results on c/js (#24003)

fixes #23915
This commit is contained in:
ringabout
2024-08-26 04:23:30 +08:00
committed by GitHub
parent 4ef06a5cc5
commit 0d53b6e027
2 changed files with 42 additions and 18 deletions

View File

@@ -47,6 +47,8 @@ block:
type DiceRoll = range[0..6]
when not defined(js):
doAssert rand(DiceRoll).int == 3
elif compileOption("jsbigint64"):
doAssert rand(DiceRoll).int == 1
else:
doAssert rand(DiceRoll).int == 6
@@ -296,10 +298,13 @@ block: # bug #22360
else:
inc fc
when defined(js):
when compileOption("jsbigint64"):
doAssert (tc, fc) == (517, 483), $(tc, fc)
else:
doAssert (tc, fc) == (515, 485), $(tc, fc)
when defined(js) and not compileOption("jsbigint64"):
doAssert (tc, fc) == (515, 485), $(tc, fc)
else:
doAssert (tc, fc) == (510, 490), $(tc, fc)
block:
when defined(js) and not compileOption("jsbigint64"):
doAssert rand(int32.high) == 335507522
else:
doAssert rand(int32.high) == 607539621