Skip to content
17 changes: 17 additions & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,23 @@ end
@test ismissing(scdm[2])
end

@testset "behavior at signed zero of monotonic floating-point functions mapping zero to zero" begin
@testset "typ: $typ" for typ in (Float16, Float32, Float64)
@testset "f: $f" for f in (
# all strictly increasing
identity, deg2rad, rad2deg, cbrt, log1p, expm1, sinh, tanh, asinh, atanh,
sin, sind, sinpi, tan, tand, tanpi, asin, asind, atan, atand,
Base.Fix1(round, typ), Base.Fix1(trunc, typ), ∘(-, -), ∘(-, cosc),
)
@testset "s: $s" for s in (-1, 1)
z = s * typ(0)
z::typ
@test z === @inferred f(z)
end
end
end
end

@testset "Integer and Inf args for sinpi/cospi/tanpi/sinc/cosc" begin
for (sinpi, cospi) in ((sinpi, cospi), (x->sincospi(x)[1], x->sincospi(x)[2]))
@test sinpi(1) === 0.0
Expand Down