'math.randomseed' always returns the two seed components

This commit is contained in:
Roberto Ierusalimschy
2019-07-19 13:31:53 -03:00
parent 3c0d3c6fbe
commit 2f22c6bb79
3 changed files with 15 additions and 11 deletions

View File

@@ -842,9 +842,11 @@ end
do
-- testing return of 'randomseed'
local <const> x, <const> y = math.randomseed()
local x, y = math.randomseed()
local res = math.random(0)
math.randomseed(x, y) -- should repeat the state
x, y = math.randomseed(x, y) -- should repeat the state
assert(math.random(0) == res)
math.randomseed(x, y) -- again should repeat the state
assert(math.random(0) == res)
-- keep the random seed for following tests
end