Skip to content

Commit

Permalink
Add test for random module that checks platform in order to pass test…
Browse files Browse the repository at this point in the history
… and avoid issues in JuliaLang#5999
  • Loading branch information
Joseph Perla committed Mar 2, 2014
1 parent a5b5d64 commit 97f3cb4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
@test length(randn(4, 5)) == 20
@test length(randbool(4, 5)) == 20

rng = MersenneTwister(0)

# Currently, the MersenneTwister for 64-bit outputs different
# random numbers on 32- versus 64-bit systems.
# This if-statement be unnecessary once this is fixed.
if WORD_SIZE == 64
@test (rand(rng) - 0.07749284875576845) < 0.01
elseif WORD_SIZE == 32
@test (rand(rng) - 0.8236475079774124) < 0.01
end

for T in (Int8, Uint8, Int16, Uint16, Int32, Uint32, Int64, Uint64, Int128, Uint128, Char, BigInt,
Float16, Float32, Float64, Rational{Int})
r = rand(convert(T, 97):convert(T, 122))
Expand Down

0 comments on commit 97f3cb4

Please sign in to comment.