Skip to content

Commit

Permalink
Merge pull request #5993 from jperla/master
Browse files Browse the repository at this point in the history
Add more unit tests for test/random.jl in preparation for refactor
  • Loading branch information
jiahao committed Mar 1, 2014
2 parents 475eb52 + e013517 commit 4dfbecc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/random.jl
Expand Up @@ -6,6 +6,13 @@
@test minimum([rand(int32(1):int32(7^7)) for i = 1:100000]) > 0
@test(typeof(rand(false:true)) == Bool)

@test length(randn(4, 5)) == 20
@test length(randbool(4, 5)) == 20

# Test Reproducibility of Pseudo-Random Numbers
rng = MersenneTwister(0)

This comment has been minimized.

Copy link
@rickhg12hs

rickhg12hs Mar 1, 2014

Contributor

Need a platform independent seed value.

This comment has been minimized.

Copy link
@jiahao

jiahao Mar 1, 2014

Author Member

Good catch. I'll have to revert this.

This comment has been minimized.

Copy link
@andreasnoack

andreasnoack Mar 1, 2014

Member

What about having uint32(seed) in line 36 of random.jl instead reinterpret(Uint32,[seed])?

This comment has been minimized.

Copy link
@jiahao

jiahao Mar 1, 2014

Author Member

@rickhg12hs could you try this?

This comment has been minimized.

Copy link
@rickhg12hs

rickhg12hs Mar 3, 2014

Contributor

Sorry, just saw this. Do you still need me to try this? I have only a 32-bit platform.

This comment has been minimized.

Copy link
@jiahao

jiahao Mar 3, 2014

Author Member

I don't think it's necessary anymore. This appears to be a deeper design issue.

This comment has been minimized.

Copy link
@rickhg12hs

rickhg12hs Mar 3, 2014

Contributor

Maybe #6023 fixes this? I didn't catch the underlying issues.

@test (rand(rng) - 0.07749284875576845) < 0.01

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

1 comment on commit 4dfbecc

@jperla
Copy link

@jperla jperla commented on 4dfbecc Mar 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jiahao I expected this one to go through which fixes the randomness differences: #6018 (comment)

Please sign in to comment.