Skip to content

Commit

Permalink
Use test_throws instead of test_broken in Float16 numbers tests
Browse files Browse the repository at this point in the history
Since test_broken is not good for things that currently error
but when fixed will return non-boolean.

If you know how to fix the inference issue and get tests to pass
with #17394 (377dede) reverted,
then please do so and ignore this change.
  • Loading branch information
tkelman committed Jul 13, 2016
1 parent 254891c commit 56ebf27
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2771,7 +2771,8 @@ let types = (Base.BitInteger_types..., BigInt, Bool,
for S in types
for op in (+, -)
if S === Float16 # type instability here?
@test_broken @inferred Base.promote_op(op, S)
# broken, fixme then remove this branch
@test_throws ErrorException @inferred(Base.promote_op(op, S))
T = Base.promote_op(op, S)
else
T = @inferred Base.promote_op(op, S)
Expand All @@ -2785,11 +2786,31 @@ let types = (Base.BitInteger_types..., BigInt, Bool,

for R in types, S in types
for op in (+, -, *, /, ^)
if R in (Float16, Complex{Float16}) || S in (Float16, Complex{Float16})
@test_broken @inferred Base.promote_op(op, R, S)
if R === Float16 || S === Float16
# broken, fixme then remove this branch
@test_throws ErrorException @inferred(Base.promote_op(op, R, S))
T = Base.promote_op(op, R, S)
@test_broken @inferred op(one(R), one(S))
t = op(one(R), one(S))
if ((R === Bool || S === Bool) && op in (+, *)) ||
((S in (Rational{Int}, Complex{Float16})) && op === ^) ||
(R === Complex{Float16} && op === ^)
@test_throws ErrorException @inferred(op(one(R), one(S)))
t = op(one(R), one(S))
else
t = @inferred op(one(R), one(S))
end
elseif R === Complex{Float16} || S === Complex{Float16}
# broken, fixme then remove this branch too
if (R === Bool && op in (+, *, /, ^)) ||
(S === Bool && op in (+, *)) ||
(S in (R, Rational{Int}) && op === ^)
@test_throws ErrorException @inferred(Base.promote_op(op, R, S))
T = Base.promote_op(op, R, S)
@test_throws ErrorException @inferred(op(one(R), one(S)))
t = op(one(R), one(S))
else
T = @inferred Base.promote_op(op, R, S)
t = @inferred op(one(R), one(S))
end
else
T = @inferred Base.promote_op(op, R, S)
t = @inferred op(one(R), one(S))
Expand All @@ -2805,7 +2826,8 @@ let types = (Base.BitInteger_types..., BigInt, Bool,
for S in types, T in types
for op in (<, >, <=, >=, (==))
if S === Float16 || T === Float16
@test_broken @inferred(Base.promote_op(op, S, T))
# broken, fixme then remove this branch
@test_throws ErrorException @inferred(Base.promote_op(op, S, T))
@test Base.promote_op(op, S, T) === Bool
else
@test @inferred(Base.promote_op(op, S, T)) === Bool
Expand Down

0 comments on commit 56ebf27

Please sign in to comment.