Skip to content

Commit fcd9eb3

Browse files
committed
Add a couple of tests for Base.mul_hi
1 parent 5a91766 commit fcd9eb3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/numbers.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,6 +2523,22 @@ Base.:(==)(x::TestNumber, y::TestNumber) = x.inner == y.inner
25232523
Base.abs(x::TestNumber) = TestNumber(abs(x.inner))
25242524
@test abs2(TestNumber(3+4im)) == TestNumber(25)
25252525

2526+
@testset "mul_hi" begin
2527+
n = 1000
2528+
ground_truth(x, y) = ((widen(x)*y) >> (8*sizeof(typeof(x)))) % typeof(x)
2529+
for T in [UInt8, UInt16, UInt32, UInt64, UInt128, Int8, Int16, Int32, Int64, Int128]
2530+
for trait1 in [typemin, typemax]
2531+
for trait2 in [typemin, typemax]
2532+
x, y = trait1(T), trait2(T)
2533+
@test Base.mul_hi(x, y) === ground_truth(x, y)
2534+
end
2535+
end
2536+
for (x, y) in zip(rand(T, n), rand(T, n))
2537+
@test Base.mul_hi(x, y) === ground_truth(x, y)
2538+
end
2539+
end
2540+
end
2541+
25262542
@testset "multiplicative inverses" begin
25272543
function testmi(numrange, denrange)
25282544
for d in denrange

0 commit comments

Comments
 (0)