Skip to content

Commit

Permalink
Improve instability tests of return type: === && isa
Browse files Browse the repository at this point in the history
Make all the inferred tests actually test the return type is the correct
type by comparing `===` instead of `==`.
Make the unary test `@inferred(typemax(FD{T,f}))` test that the return
type is the correct type via `isa`.
  • Loading branch information
NHDaly committed Feb 13, 2019
1 parent 8cf3523 commit 0b4c48c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -794,24 +794,24 @@ end
frange = filter(f->f<=maxF, fs)
# Unary operations
@testset for f in frange
@test @inferred(zero(FD{T,f}(1))) == FD{T,f}(0)
@test @inferred(one(FD{T,f}(1))) == FD{T,f}(1)
@test @inferred(ceil(FD{T,f}(1))) == FD{T,f}(1)
@test @inferred(round(FD{T,f}(1))) == FD{T,f}(1)
@test @inferred(abs(FD{T,f}(1))) == FD{T,f}(1)
@test @inferred(FD{T,f}(1)^2) == FD{T,f}(1)
@test (@inferred(typemax(FD{T,f})); true)
@test @inferred(zero(FD{T,f}(1))) === FD{T,f}(0)
@test @inferred(one(FD{T,f}(1))) === FD{T,f}(1)
@test @inferred(ceil(FD{T,f}(1))) === FD{T,f}(1)
@test @inferred(round(FD{T,f}(1))) === FD{T,f}(1)
@test @inferred(abs(FD{T,f}(1))) === FD{T,f}(1)
@test @inferred(FD{T,f}(1)^2) === FD{T,f}(1)
@test @inferred(typemax(FD{T,f})) isa FD{T,f}
end
# Binary operations
@testset for (f1,f2) in Iterators.product(frange, frange)
fmax = max(f1,f2)
@test @inferred(FD{T,f1}(1) + FD{T,f2}(0)) == FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) - FD{T,f2}(0)) == FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) * FD{T,f2}(1)) == FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) / FD{T,f2}(1)) == FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) ÷ FD{T,f2}(1)) == FD{T,fmax}(1)
@test @inferred(max(FD{T,f1}(1), FD{T,f2}(0))) == FD{T,fmax}(1)
@test @inferred(min(FD{T,f1}(1), FD{T,f2}(0))) == FD{T,fmax}(0)
@test @inferred(FD{T,f1}(1) + FD{T,f2}(0)) === FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) - FD{T,f2}(0)) === FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) * FD{T,f2}(1)) === FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) / FD{T,f2}(1)) === FD{T,fmax}(1)
@test @inferred(FD{T,f1}(1) ÷ FD{T,f2}(1)) === FD{T,fmax}(1)
@test @inferred(max(FD{T,f1}(1), FD{T,f2}(0))) === FD{T,fmax}(1)
@test @inferred(min(FD{T,f1}(1), FD{T,f2}(0))) === FD{T,fmax}(0)
end
end
end
Expand Down

0 comments on commit 0b4c48c

Please sign in to comment.