Skip to content

Commit 735b7f9

Browse files
authored
Change test targets of Fixed (#218)
1 parent 5dcaf97 commit 735b7f9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

test/common.jl

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

test/fixed.jl

Lines changed: 9 additions & 5 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))
@@ -113,7 +113,11 @@ end
113113
f < bitwidth(T) - 1 && @test one(F) == 1
114114
f < bitwidth(T) - 1 && @test one(F) * oneunit(F) == oneunit(F)
115115
@test typemin(F) == typemin(T) >> f
116-
@test typemax(F) == typemax(T)//big"2"^f
116+
if T === Int128
117+
@test typemax(F) * big"2"^f == typemax(T)
118+
else
119+
@test typemax(F) == typemax(T)//big"2"^f
120+
end
117121
@test floatmin(F) === eps(F) == 2.0^-f # issue #79
118122
@test floatmax(F) === typemax(F)
119123
@test eps(zero(F)) === eps(typemax(F))
@@ -343,8 +347,8 @@ end
343347
xys = ((x, y) for x in xs, y in xs)
344348
fsub(x, y) = float(x) - float(y)
345349
@test all(((x, y),) -> wrapping_add(wrapping_sub(x, y), y) === x, xys)
346-
@test all(((x, y),) -> saturating_sub(x, y) == clamp(fsub(x, y), F), xys)
347-
@test all(((x, y),) -> !(typemin(F) < fsub(x, y) < typemax(F)) ||
350+
@test all(((x, y),) -> saturating_sub(x, y) === clamp(fsub(x, y), F), xys)
351+
@test all(((x, y),) -> !(typemin(F) <= fsub(x, y) <= typemax(F)) ||
348352
wrapping_sub(x, y) === checked_sub(x, y) === fsub(x, y) % F, xys)
349353
end
350354
end

0 commit comments

Comments
 (0)