1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Fix Lua PseudoRandom seeds being mangled

closes #14237
This commit is contained in:
sfan5 2024-01-10 20:00:14 +01:00
parent e83530d40b
commit d20f1182f2
2 changed files with 8 additions and 5 deletions

View file

@ -1,8 +1,11 @@
local function test_random()
-- Try out PseudoRandom
local pseudo = PseudoRandom(13)
assert(pseudo:next() == 22290)
assert(pseudo:next() == 13854)
-- We have comprehensive unit tests in C++, this is just to make sure the API code isn't messing up
local pr = PseudoRandom(13)
assert(pr:next() == 22290)
assert(pr:next() == 13854)
local pr2 = PseudoRandom(-101)
assert(pr2:next(0, 100) == 35)
end
unittests.register("test_random", test_random)