Skip to content

Commit 5912ace

Browse files
committed
fix tests
1 parent 373926e commit 5912ace

1 file changed

Lines changed: 15 additions & 39 deletions

File tree

test/math.jl

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -309,48 +309,24 @@ end
309309
end
310310

311311
@testset "exp function" for T in (Float64, Float32, Float16)
312-
@testset "$T accuracy" begin
313-
X = map(T, vcat(-10:0.0002:10, -80:0.001:80, 2.0^-27, 2.0^-28, 2.0^-14, 2.0^-13))
314-
for x in X
315-
y, yb = exp(x), exp(big(x))
316-
@test y===T(yb) || abs(y-yb) <= 1.0*eps(T(yb))
317-
end
318-
end
319-
@testset "$T edge cases" begin
320-
@test isnan_type(T, exp(T(NaN)))
321-
@test exp(T(-Inf)) === T(0.0)
322-
@test exp(T(Inf)) === T(Inf)
323-
@test exp(T(NaN)) === T(NaN)
324-
@test exp(T(0.0)) === T(1.0) # exact
325-
@test exp(T(5000.0)) === T(Inf)
326-
@test exp(T(-5000.0)) === T(0.0)
327-
end
328-
end
329-
330-
@testset "exp10 function" begin
331-
@testset "accuracy" begin
332-
X = map(Float64, vcat(-10:0.00021:10, -35:0.0023:100, -300:0.001:300))
333-
for x in X
334-
y, yb = exp10(x), exp10(big(x))
335-
@test y===T(yb) || abs(y-yb) <= 1.2*eps(Float64(yb))
312+
for func in (exp2,exp,exp10)
313+
@testset "$T $func accuracy" begin
314+
X = map(T, vcat(-10:0.00021:10, -300:0.001:300, 2.0^-27, 2.0^-28, 2.0^-14, 2.0^-13))
315+
for x in X
316+
y, yb = func(x), func(big(x))
317+
@test y===T(yb) || abs(y-yb) <= 1.2*eps(T(yb))
318+
end
336319
end
337-
X = map(Float32, vcat(-10:0.00021:10, -35:0.0023:35, -35:0.001:35))
338-
for x in X
339-
y, yb = exp10(x), exp10(big(x))
340-
@test y===T(yb) || abs(y-yb) <= 1.2*eps(Float32(yb))
320+
@testset "$T $func edge cases" begin
321+
@test isnan_type(T, exp(T(NaN)))
322+
@test func(T(-Inf)) === T(0.0)
323+
@test func(T(Inf)) === T(Inf)
324+
@test func(T(NaN)) === T(NaN)
325+
@test func(T(0.0)) === T(1.0) # exact
326+
@test func(T(5000.0)) === T(Inf)
327+
@test func(T(-5000.0)) === T(0.0)
341328
end
342329
end
343-
@testset "$T edge cases" for T in (Float64, Float32, Float16)
344-
@test isnan_type(T, exp10(T(NaN)))
345-
@test exp10(T(-Inf)) === T(0.0)
346-
@test exp10(T(Inf)) === T(Inf)
347-
@test exp(T(NaN)) === T(NaN)
348-
@test exp10(T(0.0)) === T(1.0) # exact
349-
@test exp10(T(1.0)) === T(10.0)
350-
@test exp10(T(3.0)) === T(1000.0)
351-
@test exp10(T(5000.0)) === T(Inf)
352-
@test exp10(T(-5000.0)) === T(0.0)
353-
end
354330
end
355331

356332
@testset "test abstractarray trig functions" begin

0 commit comments

Comments
 (0)