Skip to content

Commit

Permalink
tests: fix love.math.randomNormal test consistency
Browse files Browse the repository at this point in the history
also test exact values to make sure the tests cover algorithm changes
  • Loading branch information
slime73 committed Dec 23, 2023
1 parent eb552df commit cb4cb80
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions testing/tests/math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,24 +325,17 @@ end
-- love.math.random
love.test.math.random = function(test)
-- check some random ranges
test:assertRange(love.math.random(10), 1, 10, 'check within 1 - 10')
test:assertRange(love.math.random(10), 1, 10, 'check within 1 - 10')
test:assertRange(love.math.random(10), 1, 10, 'check within 1 - 10')
test:assertRange(love.math.random(10), 1, 10, 'check within 1 - 10')
test:assertRange(love.math.random(10), 1, 10, 'check within 1 - 10')
test:assertRange(love.math.random(5, 100), 5, 100, 'check within 5 - 100')
test:assertRange(love.math.random(5, 100), 5, 100, 'check within 5 - 100')
test:assertRange(love.math.random(5, 100), 5, 100, 'check within 5 - 100')
test:assertRange(love.math.random(5, 100), 5, 100, 'check within 5 - 100')
test:assertRange(love.math.random(5, 100), 5, 100, 'check within 5 - 100')
love.math.setRandomSeed(123)
test:assertRange(love.math.random(), 0.37068322251462, 0.37068322251464, "check random algorithm")
test:assertEquals(love.math.random(10), 4, "check single random param")
test:assertEquals(love.math.random(15, 100), 92, "check two random params")
end


-- love.math.randomNormal
-- @NOTE i dont _really_ get the range expected based on stddev + mean
-- so feel free to change to be more accurate
love.test.math.randomNormal = function(test)
test:assertRange(love.math.randomNormal(1, 0), -3, 3, 'check within -3 - 3')
love.math.setRandomSeed(1234)
test:assertRange(love.math.randomNormal(1, 2), 1.0813614997253, 1.0813614997255, 'check randomNormal two params')
end


Expand Down

0 comments on commit cb4cb80

Please sign in to comment.