|
45 | 45 | @testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}] |
46 | 46 | MA.Test.int_test(T) |
47 | 47 | @testset "Allocation" begin |
48 | | - a, b = T(2), T(3) |
49 | | - a + b, a - b, a * b # compilation |
50 | | - # Test that the MA methods have fewer allocated than the Base method |
51 | | - n = T <: Rational ? (@allocated a + b) - 1 : 0 |
52 | | - allocation_test(+, T, MA.add!!, MA.add_to!!, n) |
53 | | - n = T <: Rational ? (@allocated a - b) - 1 : 0 |
54 | | - allocation_test(-, T, MA.sub!!, MA.sub_to!!, n) |
55 | | - n = T <: Rational ? (@allocated a * b) - 1 : 0 |
56 | | - allocation_test(*, T, MA.mul!!, MA.mul_to!!, n) |
| 48 | + MAX_ALLOC = T <: Rational ? 240 : 0 |
| 49 | + allocation_test(+, T, MA.add!!, MA.add_to!!, MAX_ALLOC) |
| 50 | + allocation_test(-, T, MA.sub!!, MA.sub_to!!, MAX_ALLOC) |
| 51 | + allocation_test(*, T, MA.mul!!, MA.mul_to!!, MAX_ALLOC) |
57 | 52 | add_sub_mul_test(MA.add_mul, T) |
58 | 53 | add_sub_mul_test(MA.sub_mul, T) |
59 | 54 | if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 |
|
62 | 57 | T, |
63 | 58 | MA.add!!, |
64 | 59 | MA.add_to!!, |
65 | | - (@allocated a + b) - 1, |
| 60 | + MAX_ALLOC, |
66 | 61 | a = T(1 // 2), |
67 | 62 | b = T(3 // 2), |
68 | 63 | c = T(5 // 2), |
|
72 | 67 | T, |
73 | 68 | MA.sub!!, |
74 | 69 | MA.sub_to!!, |
75 | | - (@allocated a - b) - 1, |
| 70 | + MAX_ALLOC, |
76 | 71 | a = T(1 // 2), |
77 | 72 | b = T(3 // 2), |
78 | 73 | c = T(5 // 2), |
|
0 commit comments