Skip to content

Commit

Permalink
Fix use of Random.seed!
Browse files Browse the repository at this point in the history
Compat does not yet support Random.seed! See
[#601](JuliaLang/Compat.jl#601).
  • Loading branch information
galenlynch committed Aug 15, 2018
1 parent 7cef59f commit 66385a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/cformat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ using Compat.Random

_erfinv(z) = sqrt(π) * Base.Math.@horner(z, 0, 1, 0, π/12, 0, 7π^2/480, 0, 127π^3/40320, 0,
4369π^4/5806080, 0, 34807π^5/182476800) / 2
@static if VERSION >= v"0.7.0-beta2.171"
const srand = Random.seed!
end

function test_equality()
println( "test cformat equality...")
Random.seed!(10)
srand(10)
fmts = [ (x->@sprintf("%10.4f",x), "%10.4f"),
(x->@sprintf("%f", x), "%f"),
(x->@sprintf("%e", x), "%e"),
Expand Down Expand Up @@ -68,20 +71,20 @@ println( "integer sprintf speed, bypass repeated lookup")
@time runtime_int_bypass()

function native_float()
Random.seed!( 10 )
srand( 10 )
for i in 1:200000
@sprintf( "%10.4f", _erfinv( rand() ) )
end
end
function runtime_float()
Random.seed!( 10 )
srand( 10 )
for i in 1:200000
sprintf1( "%10.4f", _erfinv( rand() ) )
end
end
function runtime_float_bypass()
f = generate_formatter( "%10.4f" )
Random.seed!( 10 )
srand( 10 )
for i in 1:200000
f( _erfinv( rand() ) )
end
Expand Down

0 comments on commit 66385a8

Please sign in to comment.