|
82 | 82 | end
|
83 | 83 |
|
84 | 84 | @testset "inexactness" begin
|
85 |
| - @test_throws InexactError Q0f7(-2) |
86 | 85 | # TODO: change back to InexactError when it allows message strings
|
| 86 | + @test_throws ArgumentError Q0f7(-2) |
87 | 87 | @test_throws ArgumentError one(Q0f15)
|
88 | 88 | @test_throws ArgumentError oneunit(Q0f31)
|
89 | 89 | @test_throws ArgumentError one(Fixed{Int8,8}) # TODO: remove this at end of its support
|
|
92 | 92 | @testset "conversion" begin
|
93 | 93 | @test isapprox(convert(Fixed{Int8,7}, 0.8), 0.797, atol=0.001)
|
94 | 94 | @test isapprox(convert(Fixed{Int8,7}, 0.9), 0.898, atol=0.001)
|
95 |
| - @test_throws InexactError convert(Fixed{Int8, 7}, 0.999) |
96 |
| - @test_throws InexactError convert(Fixed{Int8, 7}, 1.0) |
97 |
| - @test_throws InexactError convert(Fixed{Int8, 7}, 1) |
98 |
| - @test_throws InexactError convert(Fixed{Int8, 7}, 2) |
99 |
| - @test_throws InexactError convert(Fixed{Int8, 7}, 128) |
| 95 | + @test_throws ArgumentError convert(Fixed{Int8, 7}, 0.999) |
| 96 | + @test_throws ArgumentError convert(Fixed{Int8, 7}, 1.0) |
| 97 | + @test_throws ArgumentError convert(Fixed{Int8, 7}, 1) |
| 98 | + @test_throws ArgumentError convert(Fixed{Int8, 7}, 2) |
| 99 | + @test_throws ArgumentError convert(Fixed{Int8, 7}, 128) |
| 100 | + @test_throws ArgumentError convert(Fixed{Int8, 7}, 1.0) |
| 101 | + |
| 102 | + @test convert(Q0f7, -128.5/128) == -1 |
| 103 | + |
| 104 | + @test convert(Q0f7, -0.75f0) == -0.75 |
| 105 | + @test convert(Q0f7, Float16(-0.75)) == -0.75 |
| 106 | + @test convert(Q0f7, BigFloat(-0.75)) == -0.75 |
| 107 | + @test_throws ArgumentError convert(Q0f7, BigFloat(127.5/128)) |
100 | 108 |
|
101 | 109 | @test convert(Q2f5, -1//2) === -0.5Q2f5
|
102 | 110 | @test convert(Q1f6, Rational{Int8}(-3//4)) === -0.75Q1f6
|
|
105 | 113 | @test_throws ArgumentError convert(Q0f7, typemax(Rational{Int8}))
|
106 | 114 |
|
107 | 115 | @test convert(Q0f7, Base.TwicePrecision(0.5)) === 0.5Q0f7
|
108 |
| - @test_throws InexactError convert(Q7f8, Base.TwicePrecision(0x80, 0x01)) |
| 116 | + @test_throws ArgumentError convert(Q7f8, Base.TwicePrecision(0x80, 0x01)) |
109 | 117 | tp = Base.TwicePrecision(0xFFFFFFFFp-32, 0xFFFFFFFEp-64)
|
110 | 118 | @test convert(Q0f63, tp) === reinterpret(Q0f63, typemax(Int64))
|
111 | 119 | end
|
|
0 commit comments