From b3d2f3055c1d663b0790414c93d04874be6fc7e4 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Tue, 6 Sep 2016 04:21:48 -0700 Subject: [PATCH] Rename a few 'err' variables to avoid invalid redefinition errors when running test/math.jl and test/misc.jl on the same worker --- test/math.jl | 44 ++++++++++++++++++++++---------------------- test/misc.jl | 6 ++++-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/test/math.jl b/test/math.jl index eba7910098b4c..56b7d8b1847f6 100644 --- a/test/math.jl +++ b/test/math.jl @@ -645,13 +645,13 @@ end @test !get_zero_subnormals() # useful test functions for relative error, which differ from isapprox -# in that errc separately looks at the real and imaginay parts -err(z, x) = z == x ? 0.0 : abs(z - x) / abs(x) -errc(z, x) = max(err(real(z),real(x)), err(imag(z),imag(x))) -≅(a,b) = errc(a,b) ≤ 1e-13 +# in that relerrc separately looks at the real and imaginary parts +relerr(z, x) = z == x ? 0.0 : abs(z - x) / abs(x) +relerrc(z, x) = max(relerr(real(z),real(x)), relerr(imag(z),imag(x))) +≅(a,b) = relerrc(a,b) ≤ 1e-13 for x in -10.2:0.3456:50 - @test 1e-12 > err(digamma(x+0im), digamma(x)) + @test 1e-12 > relerr(digamma(x+0im), digamma(x)) end # digamma, trigamma, polygamma & zeta test cases (compared to Wolfram Alpha) @@ -664,19 +664,19 @@ end @test polygamma(2, 8.1+0im) ≅ -0.01723882695611191078960494454602091934457319791968308929600 @test polygamma(30, 8.1+2im) ≅ -2722.8895150799704384107961215752996280795801958784600407589+6935.8508929338093162407666304759101854270641674671634631058im @test polygamma(3, 2.1+1im) ≅ 0.00083328137020421819513475400319288216246978855356531898998-0.27776110819632285785222411186352713789967528250214937861im -@test 1e-11 > err(polygamma(3, -4.2 + 2im),-0.0037752884324358856340054736472407163991189965406070325067-0.018937868838708874282432870292420046797798431078848805822im) +@test 1e-11 > relerr(polygamma(3, -4.2 + 2im),-0.0037752884324358856340054736472407163991189965406070325067-0.018937868838708874282432870292420046797798431078848805822im) @test polygamma(13, 5.2 - 2im) ≅ 0.08087519202975913804697004241042171828113370070289754772448-0.2300264043021038366901951197725318713469156789541415899307im -@test 1e-11 > err(polygamma(123, -47.2 + 0im), 5.7111648667225422758966364116222590509254011308116701029e291) +@test 1e-11 > relerr(polygamma(123, -47.2 + 0im), 5.7111648667225422758966364116222590509254011308116701029e291) @test zeta(4.1+0.3im, -3.2+0.1im) ≅ -281.34474134962502296077659347175501181994490498591796647 + 286.55601240093672668066037366170168712249413003222992205im @test zeta(4.1+0.3im, 3.2+0.1im) ≅ 0.0121197525131633219465301571139288562254218365173899270675-0.00687228692565614267981577154948499247518236888933925740902im @test zeta(4.1, 3.2+0.1im) ≅ 0.0137637451187986846516125754047084829556100290057521276517-0.00152194599531628234517456529686769063828217532350810111482im -@test 1e-12 > errc(zeta(1.0001, -4.5e2+3.2im), 10003.765660925877260544923069342257387254716966134385170 - 0.31956240712464746491659767831985629577542514145649468090im) +@test 1e-12 > relerrc(zeta(1.0001, -4.5e2+3.2im), 10003.765660925877260544923069342257387254716966134385170 - 0.31956240712464746491659767831985629577542514145649468090im) @test zeta(3.1,-4.2) ≅ zeta(3.1,-4.2+0im) ≅ 149.7591329008219102939352965761913107060718455168339040295 -@test 1e-15 > errc(zeta(3.1+0im,-4.2), zeta(3.1,-4.2+0im)) +@test 1e-15 > relerrc(zeta(3.1+0im,-4.2), zeta(3.1,-4.2+0im)) @test zeta(3.1,4.2) ≅ 0.029938344862645948405021260567725078588893266227472565010234 @test zeta(27, 3.1) ≅ 5.413318813037879056337862215066960774064332961282599376e-14 @test zeta(27, 2) ≅ 7.4507117898354294919810041706041194547190318825658299932e-9 -@test 1e-12 > err(zeta(27, -105.3), 1.3113726525492708826840989036205762823329453315093955e14) +@test 1e-12 > relerr(zeta(27, -105.3), 1.3113726525492708826840989036205762823329453315093955e14) @test polygamma(4, -3.1+Inf*im) == polygamma(4, 3.1+Inf*im) == 0 @test polygamma(4, -0.0) == Inf == -polygamma(4, +0.0) @test zeta(4, +0.0) == zeta(4, -0.0) ≅ pi^4 / 90 @@ -722,20 +722,20 @@ a1 = 2 c = 3 @test @evalpoly(c, a0, a1) == 7 -@test 1e-14 > err(eta(1+1e-9), 0.693147180719814213126976796937244130533478392539154928250926) -@test 1e-14 > err(eta(1+5e-3), 0.693945708117842473436705502427198307157819636785324430166786) -@test 1e-13 > err(eta(1+7.1e-3), 0.694280602623782381522315484518617968911346216413679911124758) -@test 1e-13 > err(eta(1+8.1e-3), 0.694439974969407464789106040237272613286958025383030083792151) -@test 1e-13 > err(eta(1 - 2.1e-3 + 2e-3 * im), 0.69281144248566007063525513903467244218447562492555491581+0.00032001240133205689782368277733081683574922990400416791019im) -@test 1e-13 > err(eta(1 + 5e-3 + 5e-3 * im), 0.69394652468453741050544512825906295778565788963009705146+0.00079771059614865948716292388790427833787298296229354721960im) -@test 1e-12 > errc(zeta(1e-3+1e-3im), -0.5009189365276307665899456585255302329444338284981610162-0.0009209468912269622649423786878087494828441941303691216750im) -@test 1e-13 > errc(zeta(1e-4 + 2e-4im), -0.5000918637469642920007659467492165281457662206388959645-0.0001838278317660822408234942825686513084009527096442173056im) +@test 1e-14 > relerr(eta(1+1e-9), 0.693147180719814213126976796937244130533478392539154928250926) +@test 1e-14 > relerr(eta(1+5e-3), 0.693945708117842473436705502427198307157819636785324430166786) +@test 1e-13 > relerr(eta(1+7.1e-3), 0.694280602623782381522315484518617968911346216413679911124758) +@test 1e-13 > relerr(eta(1+8.1e-3), 0.694439974969407464789106040237272613286958025383030083792151) +@test 1e-13 > relerr(eta(1 - 2.1e-3 + 2e-3 * im), 0.69281144248566007063525513903467244218447562492555491581+0.00032001240133205689782368277733081683574922990400416791019im) +@test 1e-13 > relerr(eta(1 + 5e-3 + 5e-3 * im), 0.69394652468453741050544512825906295778565788963009705146+0.00079771059614865948716292388790427833787298296229354721960im) +@test 1e-12 > relerrc(zeta(1e-3+1e-3im), -0.5009189365276307665899456585255302329444338284981610162-0.0009209468912269622649423786878087494828441941303691216750im) +@test 1e-13 > relerrc(zeta(1e-4 + 2e-4im), -0.5000918637469642920007659467492165281457662206388959645-0.0001838278317660822408234942825686513084009527096442173056im) # Issue #7169: (TODO: better accuracy should be possible?) -@test 1e-9 > errc(zeta(0 + 99.69im), 4.67192766128949471267133846066040655597942700322077493021802+3.89448062985266025394674304029984849370377607524207984092848im) -@test 1e-12 > errc(zeta(3 + 99.69im), 1.09996958148566565003471336713642736202442134876588828500-0.00948220959478852115901654819402390826992494044787958181148im) -@test 1e-9 > errc(zeta(-3 + 99.69im), 10332.6267578711852982128675093428012860119184786399673520976+13212.8641740351391796168658602382583730208014957452167440726im) -@test 1e-13 > errc(zeta(2 + 99.69im, 1.3), 0.41617652544777996034143623540420694985469543821307918291931-0.74199610821536326325073784018327392143031681111201859489991im) +@test 1e-9 > relerrc(zeta(0 + 99.69im), 4.67192766128949471267133846066040655597942700322077493021802+3.89448062985266025394674304029984849370377607524207984092848im) +@test 1e-12 > relerrc(zeta(3 + 99.69im), 1.09996958148566565003471336713642736202442134876588828500-0.00948220959478852115901654819402390826992494044787958181148im) +@test 1e-9 > relerrc(zeta(-3 + 99.69im), 10332.6267578711852982128675093428012860119184786399673520976+13212.8641740351391796168658602382583730208014957452167440726im) +@test 1e-13 > relerrc(zeta(2 + 99.69im, 1.3), 0.41617652544777996034143623540420694985469543821307918291931-0.74199610821536326325073784018327392143031681111201859489991im) for z in (1.234, 1.234 + 5.678im) @test cis(z) ≈ exp(im*z) diff --git a/test/misc.jl b/test/misc.jl index a5f89d8512cf7..d7fe331d5a63c 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -446,7 +446,9 @@ if is_windows() addr = addr-(UInt64(addr)%4096) const PAGE_EXECUTE_READWRITE = 0x40 oldPerm = Ref{UInt32}() - err = ccall(:VirtualProtect,stdcall,Cint,(Ptr{Void}, Csize_t, UInt32, Ptr{UInt32}), addr, 4096, PAGE_EXECUTE_READWRITE, oldPerm) - err == 0 && error(Libc.GetLastError()) + err18083 = ccall(:VirtualProtect,stdcall,Cint, + (Ptr{Void}, Csize_t, UInt32, Ptr{UInt32}), + addr, 4096, PAGE_EXECUTE_READWRITE, oldPerm) + err18083 == 0 && error(Libc.GetLastError()) end end