Skip to content

Commit e6797cc

Browse files
committed
test: math: test floating-point behavior when mapping zero to zero
The idea for this addition to the test suite originates here, where stevengj suggested to do this test for `cosc` specifically: * JuliaLang#59087 (comment) This PR instead tests all applicable functions I could find.
1 parent f345ee7 commit e6797cc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/math.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,23 @@ end
590590
@test ismissing(scdm[2])
591591
end
592592

593+
@testset "behavior at signed zero of monotonic floating-point functions mapping zero to zero" begin
594+
@testset "typ: $typ" for typ in (Float32, Float64)
595+
@testset "f: $f" for f in (
596+
# all strictly increasing
597+
identity, deg2rad, rad2deg, cbrt, log1p, expm1, sinh, tanh, asinh, atanh,
598+
sin, sind, sinpi, tan, tand, tanpi, asin, asind, atan, atand,
599+
Base.Fix1(round, typ), Base.Fix1(trunc, typ), (-, -), (-, cosc),
600+
)
601+
@testset "s: $s" for s in (-1, 1)
602+
z = s * typ(0)
603+
z::typ
604+
@test z === @inferred f(z)
605+
end
606+
end
607+
end
608+
end
609+
593610
@testset "Integer and Inf args for sinpi/cospi/tanpi/sinc/cosc" begin
594611
for (sinpi, cospi) in ((sinpi, cospi), (x->sincospi(x)[1], x->sincospi(x)[2]))
595612
@test sinpi(1) === 0.0

0 commit comments

Comments
 (0)