Skip to content

Commit 452aa89

Browse files
authored
Update tests for removal of erfinv from Base (#35)
1 parent ca1ebe0 commit 452aa89

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/cformat.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ using Formatting
22
using Compat
33
using Base.Test
44

5+
_erfinv(z) = sqrt(π) * Base.Math.@horner(z, 0, 1, 0, π/12, 0, 7π^2/480, 0, 127π^3/40320, 0,
6+
4369π^4/5806080, 0, 34807π^5/182476800) / 2
7+
58
function test_equality()
69
println( "test cformat equality...")
710
srand(10)
@@ -11,7 +14,7 @@ function test_equality()
1114
l.args[2].args[2] = @compat Expr(:macrocall, Symbol("@sprintf"), fmt, :x)
1215
mfmtr = eval( l )
1316
for i in 1:10000
14-
n = erfinv( rand() * 1.99 - 1.99/2.0 )
17+
n = _erfinv( rand() * 1.99 - 1.99/2.0 )
1518
expect = mfmtr( n )
1619
actual = sprintf1( fmt, n )
1720
@test expect == actual
@@ -24,7 +27,7 @@ function test_equality()
2427
l.args[2].args[2] = @compat Expr(:macrocall, Symbol("@sprintf"), fmt, :x)
2528
mfmtr = eval( l )
2629
for i in 1:10000
27-
j = round(Int, erfinv( rand() * 1.99 - 1.99/2.0 ) * 100000 )
30+
j = round(Int, _erfinv( rand() * 1.99 - 1.99/2.0 ) * 100000 )
2831
expect = mfmtr( j )
2932
actual = sprintf1( fmt, j )
3033
@test expect == actual
@@ -64,20 +67,20 @@ println( "integer sprintf speed, bypass repeated lookup")
6467
function native_float()
6568
srand( 10 )
6669
for i in 1:200000
67-
@sprintf( "%10.4f", erfinv( rand() ) )
70+
@sprintf( "%10.4f", _erfinv( rand() ) )
6871
end
6972
end
7073
function runtime_float()
7174
srand( 10 )
7275
for i in 1:200000
73-
sprintf1( "%10.4f", erfinv( rand() ) )
76+
sprintf1( "%10.4f", _erfinv( rand() ) )
7477
end
7578
end
7679
function runtime_float_bypass()
7780
f = generate_formatter( "%10.4f" )
7881
srand( 10 )
7982
for i in 1:200000
80-
f( erfinv( rand() ) )
83+
f( _erfinv( rand() ) )
8184
end
8285
end
8386

0 commit comments

Comments
 (0)