diff --git a/test/big.jl b/test/big.jl index 3784003..2fb37c5 100644 --- a/test/big.jl +++ b/test/big.jl @@ -45,9 +45,15 @@ end @testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}] MA.Test.int_test(T) @testset "Allocation" begin - allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 224 : 0) - allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 168 : 0) - allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 280 : 0) + a, b = T(2), T(3) + a + b, a - b, a * b # compilation + # Test that the MA methods have fewer allocated than the Base method + n = T <: Rational ? (@allocated a + b) - 1 : 0 + allocation_test(+, T, MA.add!!, MA.add_to!!, n) + n = T <: Rational ? (@allocated a - b) - 1 : 0 + allocation_test(-, T, MA.sub!!, MA.sub_to!!, n) + n = T <: Rational ? (@allocated a * b) - 1 : 0 + allocation_test(*, T, MA.mul!!, MA.mul_to!!, n) add_sub_mul_test(MA.add_mul, T) add_sub_mul_test(MA.sub_mul, T) if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 @@ -56,7 +62,7 @@ end T, MA.add!!, MA.add_to!!, - 224, + (@allocated a + b) - 1, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), @@ -66,7 +72,7 @@ end T, MA.sub!!, MA.sub_to!!, - 168, + (@allocated a - b) - 1, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2),