@@ -16,7 +16,7 @@ function test_fixed(::Type{T}, f) where {T}
16
16
if ! (typemin (T) < x <= typemax (T))
17
17
continue
18
18
end
19
- isinteger (x) && @show x
19
+ # isinteger(x) && @show x
20
20
fx = convert (T,x)
21
21
@test convert (T,convert (Float64, fx)) == fx
22
22
@test convert (T,convert (Float64, - fx)) == - fx
62
62
@testset " test_fixed" begin
63
63
for (TI, f) in [(Int8, 8 ), (Int16, 8 ), (Int16, 10 ), (Int32, 16 )]
64
64
T = Fixed{TI,f}
65
- println (" Testing $T " )
65
+ # println(" Testing $T")
66
66
test_fixed (T, f)
67
67
end
68
68
end
@@ -166,4 +166,30 @@ for (T, f) in ((Int8, 7),
166
166
@test abs (Fixed {T, f} (x) - x) <= tol
167
167
end
168
168
end
169
+
170
+ @testset " Promotion within Fixed" begin
171
+ @test @inferred (promote (Q0f7 (0.25 ), Q0f7 (0.75 ))) ===
172
+ (Q0f7 (0.25 ), Q0f7 (0.75 ))
173
+ @test @inferred (promote (Fixed {Int16,3} (0.25 ), Fixed {Int8,3} (0.875 ))) ===
174
+ (Fixed {Int16,3} (0.25 ), Fixed {Int16,3} (0.875 ))
175
+ @test @inferred (promote (Fixed {Int8,6} (0.125 ), Fixed {Int8,4} (0.75 ))) ===
176
+ (Fixed {Int16,6} (0.125 ), Fixed {Int16,6} (0.75 ))
177
+
178
+ @test Fixed {Int16,15} (- 1 ) == Fixed {Int8,7} (- 1 )
179
+ @test Fixed {Int16,15} (0.25 ) == Fixed {Int8,7} (0.25 )
180
+ @test Fixed {Int16,7} (- 1 ) == Fixed {Int8,7} (- 1 )
181
+ @test Fixed {Int16,7} (0.25 ) == Fixed {Int8,7} (0.25 )
182
+ @test Fixed {Int16,15} (- 1 ) == Fixed {Int8,5} (- 1 )
183
+ @test Fixed {Int16,15} (5 / 32 ) == Fixed {Int8,5} (5 / 32 )
184
+ @test Fixed {Int16,3} (- 1 ) == Fixed {Int8,5} (- 1 )
185
+ @test Fixed {Int16,3} (0.25 ) == Fixed {Int8,5} (0.25 )
186
+
187
+ @test promote_type (Q0f7,Float32,Int) == Float32
188
+ @test promote_type (Q0f7,Int,Float32) == Float32
189
+ @test promote_type (Int,Q0f7,Float32) == Float32
190
+ @test promote_type (Int,Float32,Q0f7) == Float32
191
+ @test promote_type (Float32,Int,Q0f7) == Float32
192
+ @test promote_type (Float32,Q0f7,Int) == Float32
193
+ @test promote_type (Q0f7,Q1f6,Q2f5,Q3f4,Q4f3,Q5f2) == Fixed{Int128,7 }
194
+ end
169
195
end
0 commit comments