Skip to content

Commit 300c4fb

Browse files
committed
Test fast operators.
1 parent 08349d6 commit 300c4fb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/interface.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Base.FastMath: mul_fast, add_fast, div_fast
2+
13
function test_semiring(a::T, b::T, c::T) where {T <: AbstractSemiring}
24
# 1 is the multiplicative identity
35
@test one(T) * a a * one(T) a
@@ -56,6 +58,18 @@ function test_quantale(a::T, b::T, c::T) where {T <: AbstractSemiring}
5658
@test (a < b) == (a != b && a <= b)
5759
end
5860

61+
function test_fast(a::T, b::T, c::T) where {T <: AbstractSemiring}
62+
@test a + b add_fast(a, b)
63+
@test a * b mul_fast(a, b)
64+
@test a b inf_fast(a, b)
65+
@test a / b div_fast(a, b)
66+
@test a \ b ldiv_fast(a, b)
67+
68+
@test (a * b) + c fma(a, b, c)
69+
@test (a \ b) c fli(a, b, c)
70+
@test (a / b) c fri(a, b, c)
71+
end
72+
5973
@testset "interface" begin
6074
types = (
6175
TropicalMinPlusF64,
@@ -71,6 +85,7 @@ end
7185
b = rand(T)
7286
c = rand(T)
7387

88+
test_fast(a, b, c)
7489
test_quantale(a, b, c)
7590
test_quantale(zero(T), b, c)
7691
end
@@ -86,6 +101,7 @@ end
86101
c = 3 // 4
87102

88103
for T in types
104+
test_fast(T(a), T(b), T(c))
89105
test_quantale(T(a), T(b), T(c))
90106
test_quantale(zero(T), T(b), T(c))
91107
test_quantale(typemax(T), T(b), T(c))

0 commit comments

Comments
 (0)