@@ -50,6 +50,16 @@ function test_fixed(::Type{T}, f) where {T}
50
50
end
51
51
end
52
52
53
+ @testset " domain of f" begin
54
+ # TODO : change the upper limit
55
+ @test_logs (:warn , r" will be denied in the future" ) zero (Fixed{Int8,8 })
56
+ @test_throws DomainError zero (Fixed{Int8,- 1 })
57
+ # @test_throws DomainError zero(Fixed{Int8,8})
58
+ @test_throws DomainError zero (Fixed{Int8,9 })
59
+ # @test_throws DomainError zero(Fixed{Int16,16})
60
+ @test_throws DomainError zero (Fixed{Int16,17 })
61
+ end
62
+
53
63
@testset " reinterpret" begin
54
64
@test reinterpret (Q0f7, signed (0xa2 )) === - 0.734375 Q0f7
55
65
@test reinterpret (Q5f10, signed (0x00a2 )) === 0.158203125 Q5f10
65
75
# TODO : change back to InexactError when it allows message strings
66
76
@test_throws ArgumentError one (Q0f15)
67
77
@test_throws ArgumentError oneunit (Q0f31)
68
- @test_throws ArgumentError one (Fixed{Int8,8 })
78
+ @test_throws ArgumentError one (Fixed{Int8,8 }) # TODO : remove this at end of its support
69
79
end
70
80
71
81
@testset " conversion" begin
79
89
end
80
90
81
91
@testset " test_fixed" begin
82
- for (TI, f) in [(Int8, 8 ), (Int16, 8 ), (Int16, 10 ), (Int32, 16 )]
92
+ for (TI, f) in [(Int8, 7 ), (Int16, 8 ), (Int16, 10 ), (Int32, 16 )]
83
93
T = Fixed{TI,f}
84
94
# println(" Testing $T")
85
95
test_fixed (T, f)
112
122
end
113
123
114
124
@testset " reductions" begin
115
- F8 = Fixed{Int8,8 }
116
- a = F8[0.498 , 0.1 ]
125
+ a = Q0f7[0.75 , 0.5 ]
117
126
acmp = Float64 (a[1 ]) + Float64 (a[2 ])
118
127
@test sum (a) == acmp
119
128
@test sum (a, dims= 1 ) == [acmp]
126
135
end
127
136
128
137
@testset " convert result type" begin
129
- x = Fixed {Int8,8 } (0.3 )
138
+ x = Fixed {Int8,7 } (0.75 )
130
139
for T in (Float16, Float32, Float64, BigFloat)
131
140
y = convert (T, x)
132
141
@test isa (y, T)
@@ -154,11 +163,10 @@ end
154
163
end
155
164
156
165
@testset " rand" begin
157
- for T in (Fixed{Int8,8 }, Fixed{Int16,8 }, Fixed{Int16,10 }, Fixed{Int32,16 })
158
- a = rand (T)
159
- @test isa (a, T)
160
- a = rand (T, (3 , 5 ))
161
- @test ndims (a) == 2 && eltype (a) == T
166
+ for F in (Fixed{Int8,7 }, Fixed{Int16,8 }, Fixed{Int16,10 }, Fixed{Int32,16 })
167
+ @test isa (rand (F), F)
168
+ a = rand (F, (3 , 5 ))
169
+ @test ndims (a) == 2 && eltype (a) == F
162
170
@test size (a) == (3 ,5 )
163
171
end
164
172
end
0 commit comments