Skip to content

Commit

Permalink
improve fastmath test coverage (#34702)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramtayl authored and KristofferC committed Apr 11, 2020
1 parent 77dadd8 commit b8c38c3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fastmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,20 @@ end
@testset "literal powers" begin
@test @fastmath(2^-2) == @fastmath(2.0^-2) == 0.25
end

@testset "sincos fall-backs" begin
struct FloatWrapper
inner::Float64
end
Base.sin(outer::FloatWrapper) = sin(outer.inner)
Base.cos(outer::FloatWrapper) = cos(outer.inner)
for zilch in (FloatWrapper(0.0), 0, 0 + 0 * im)
@test (@fastmath sincos(zilch)) == (0, 1)
end
end

@testset "non-numeric fallbacks" begin
@test (@fastmath :(:sin)) == :(:sin)
@test (@fastmath "a" * "b") == "ab"
@test (@fastmath "a" ^ 2) == "aa"
end

0 comments on commit b8c38c3

Please sign in to comment.