Skip to content

Commit cdb5893

Browse files
committed
Make random test less likely to fail
Previously, one of Random's tests was checking `rand(s) != rand(s)`, where `s` was a 11001-length range. This is expected to have a one-in-11001 chance of failure, and indeed it has caused at least one CI failure. This changes it to something much less likely to spuriously fail -- if I have my probabilities right here I think it'd be on the order of 10^-20.
1 parent 12fea2d commit cdb5893

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/Random/test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ end
120120
for T in [UInt32, UInt64, UInt128, Int128]
121121
local r, s
122122
s = big(typemax(T)-1000) : big(typemax(T)) + 10000
123-
@test rand(s) != rand(s)
123+
# s is a 11001-length array
124+
@test rand(s) isa BigInt
125+
@test sum(rand(s, 1000) .== rand(s, 1000)) <= 20
124126
@test big(typemax(T)-1000) <= rand(s) <= big(typemax(T)) + 10000
125127
r = rand(s, 1, 2)
126128
@test size(r) == (1, 2)

0 commit comments

Comments
 (0)