From 0d53b6e027a66bc60ca853d57c019338bb73ba0b Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 26 Aug 2024 04:23:30 +0800 Subject: fixes #23915; std/random produces different results on c/js (#24003) fixes #23915 --- tests/stdlib/trandom.nim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tests/stdlib') diff --git a/tests/stdlib/trandom.nim b/tests/stdlib/trandom.nim index bec75c1eb..eb32f7757 100644 --- a/tests/stdlib/trandom.nim +++ b/tests/stdlib/trandom.nim @@ -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 -- cgit 1.4.1-2-gfad0