Skip to content

Commit cbb7d85

Browse files
committed
Change test targets of Fixed (JuliaMath#218)
1 parent 87f4916 commit cbb7d85

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

test/common.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ T == UInt32 |x - - - - - - -:- - - - - - - -:x - - - - - - -:- - - - - - - -|
104104
"""
105105
function target_f(X::Type, T::Type{<:Integer}; ex = :default)
106106
f_min = X === Fixed ? 0 : 1
107-
f_max = bitwidth(T) - (T <: Signed) - 1 + f_min
107+
f_max = bitwidth(T) - (T <: Signed)
108108
ex === :heavy && return f_min:f_max
109109
ex === :default && bitwidth(T) <= 16 && return f_min:f_max
110110
ex === :thin && return ((f_max + 1) ÷ 2, f_max)

test/fixed.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function test_fixed(::Type{F}) where {F}
2424
fxf = convert(Float64, fx)
2525

2626
@test convert(F, convert(Float64, fx)) === fx
27-
@test convert(F, convert(Float64, -fx)) === -fx
28-
@test convert(Float64, -fx) == -convert(Float64, fx)
27+
fx != typemin(F) && @test convert(F, convert(Float64, -fx)) === -fx
28+
fx != typemin(F) && @test convert(Float64, -fx) == -convert(Float64, fx)
2929

3030
rx = convert(Rational{BigInt}, fx)
3131
@assert isequal(fx, rx) == isequal(hash(fx), hash(rx))
@@ -96,7 +96,11 @@ end
9696
f < bitwidth(T) - 1 && @test one(F) == 1
9797
f < bitwidth(T) - 1 && @test one(F) * oneunit(F) == oneunit(F)
9898
@test typemin(F) == typemin(T) >> f
99-
@test typemax(F) == typemax(T)//big"2"^f
99+
if T === Int128
100+
@test typemax(F) * big"2"^f == typemax(T)
101+
else
102+
@test typemax(F) == typemax(T)//big"2"^f
103+
end
100104
@test floatmin(F) === eps(F) == 2.0^-f # issue #79
101105
@test floatmax(F) === typemax(F)
102106
@test eps(zero(F)) === eps(typemax(F))

0 commit comments

Comments
 (0)