Skip to content

Commit 75ed265

Browse files
committed
More
1 parent dd57fbd commit 75ed265

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/runtests.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using Test, BFloat16s, Printf, Random
66
@test Base.exponent_bits(BFloat16) == 8
77
@test Base.significand_bits(BFloat16) == 7
88
@test precision(BFloat16) == 8
9+
@test Base.uinttype(BFloat16) == UInt16
910

1011
@test typemin(BFloat16) == -BFloat16s.InfB16
1112
@test typemax(BFloat16) == BFloat16s.InfB16
@@ -33,7 +34,7 @@ end
3334
end
3435

3536
@testset "trunc" begin
36-
bf_val = 5.5
37+
bf_val = BFloat16(5.5)
3738
@testset "$Ti" for Ti in (Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128)
3839
@test trunc(Ti, bf_val) == Ti(5)
3940
end
@@ -48,12 +49,17 @@ end
4849
@test Float32(BFloat16(10)) == 1f1
4950
@test Float64(BFloat16(10)) == 10.0
5051
@test Int32(BFloat16(10)) == Int32(10)
52+
@test UInt32(BFloat16(10)) == Int32(10)
5153
@test Int64(BFloat16(10)) == Int64(10)
54+
@test UInt64(BFloat16(10)) == Int64(10)
5255
@test BFloat16(BigFloat(1)) == BFloat16(1)
5356
@test BigFloat(BFloat16(1)) == BigFloat(1)
5457
@test Float16(BFloat16(3.140625)) == Float16(π)
5558
@test BFloat16(Float16(π)) == BFloat16(3.140625)
5659

60+
@test promote(BFloat16(4.5), Float64(5.0)) == (Float64(4.5), Float64(5.0))
61+
@test promote(BFloat16(4.5), Float32(5.0)) == (Float32(4.5), Float32(5.0))
62+
5763
@test_throws InexactError Int8(BFloat16(500))
5864
@test_throws InexactError UInt8(BFloat16(500))
5965
end

0 commit comments

Comments
 (0)