Skip to content

Commit 3391b17

Browse files
committed
More/Fix
1 parent 1ececde commit 3391b17

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/runtests.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ using Test, BFloat16s, Printf, Random
22

33
@info "Testing BFloat16s" BFloat16s.llvm_storage BFloat16s.llvm_arithmetic
44

5+
@testset "BFloat16s" begin
6+
57
@testset "basics" begin
68
@test Base.exponent_bits(BFloat16) == 8
79
@test Base.significand_bits(BFloat16) == 7
@@ -35,14 +37,15 @@ end
3537

3638
@testset "trunc" begin
3739
bf_val = BFloat16(5.5)
38-
@testset "$Ti" for Ti in (Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64)
39-
@test trunc(Ti, bf_val) == Ti(5)
40+
@testset "$Ti" for Ti in (Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128)
41+
@test trunc(Ti, bf_val) == Ti(5) skip=(BFloat16s.llvm_arithmetic && sizeof(Ti) == 16)
4042
end
4143

4244
@test trunc(BFloat16, Float32(π)) == BFloat16(3.140625)
4345

4446
#InexactError
45-
@test_throws InexactError trunc(Int8,BFloat16(500))
47+
@test_throws InexactError trunc(Int16, typemax(BFloat16))
48+
@test_throws InexactError trunc(UInt16, typemax(BFloat16))
4649
end
4750

4851
@testset "conversions" begin
@@ -60,8 +63,8 @@ end
6063
@test promote(BFloat16(4.5), Float64(5.0)) == (Float64(4.5), Float64(5.0))
6164
@test promote(BFloat16(4.5), Float32(5.0)) == (Float32(4.5), Float32(5.0))
6265

63-
@test_throws InexactError Int8(BFloat16(500))
64-
@test_throws InexactError UInt8(BFloat16(500))
66+
@test_throws InexactError Int16(typemax(BFloat16))
67+
@test_throws InexactError UInt16(typemax(BFloat16))
6568
end
6669

6770
@testset "abi" begin
@@ -176,6 +179,9 @@ end
176179

177180
@test x < nextfloat(x)
178181
@test x > prevfloat(x)
182+
183+
@test nextfloat(x, typemax(Int)) == typemax(BFloat16)
184+
@test prevfloat(x, typemax(Int)) == typemin(BFloat16)
179185
end
180186

181187
@test isnan(nextfloat(BFloat16s.NaNB16))
@@ -232,3 +238,5 @@ end
232238

233239
include("structure.jl")
234240
include("mathfuncs.jl")
241+
242+
end # @testset "BFloat16s"

0 commit comments

Comments
 (0)