Skip to content

Commit e470c6b

Browse files
authored
Fix tests for Julia v1.11 and later (#314)
1 parent eccbd5f commit e470c6b

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

test/big.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ end
4545
@testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}]
4646
MA.Test.int_test(T)
4747
@testset "Allocation" begin
48-
allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 168 : 0)
49-
allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 168 : 0)
50-
allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 240 : 0)
48+
MAX_ALLOC = T <: Rational ? 280 : 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)
5152
add_sub_mul_test(MA.add_mul, T)
5253
add_sub_mul_test(MA.sub_mul, T)
5354
if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167
@@ -56,7 +57,7 @@ end
5657
T,
5758
MA.add!!,
5859
MA.add_to!!,
59-
168,
60+
MAX_ALLOC,
6061
a = T(1 // 2),
6162
b = T(3 // 2),
6263
c = T(5 // 2),
@@ -66,7 +67,7 @@ end
6667
T,
6768
MA.sub!!,
6869
MA.sub_to!!,
69-
168,
70+
MAX_ALLOC,
7071
a = T(1 // 2),
7172
b = T(3 // 2),
7273
c = T(5 // 2),

test/broadcast.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ end
3030
@test x == 4
3131
@test y == 5
3232
# FIXME This should not allocate but I couldn't figure out where these
33-
# 240 come from.
34-
alloc_test(() -> MA.broadcast!!(+, a, b), 30 * sizeof(Int))
33+
# allocations come from.
34+
n = (VERSION >= v"1.11" ? 42 : 30) * sizeof(Int)
35+
alloc_test(() -> MA.broadcast!!(+, a, b), n)
3536
alloc_test(() -> MA.broadcast!!(+, a, c), 0)
3637
end
3738

test/dummy.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Base.copy(x::DummyBigInt) = x
3131
MA.mutable_copy(x::DummyBigInt) = DummyBigInt(MA.mutable_copy(x.data))
3232
LinearAlgebra.symmetric_type(::Type{DummyBigInt}) = DummyBigInt
3333
LinearAlgebra.symmetric(x::DummyBigInt, ::Symbol) = x
34+
LinearAlgebra.issymmetric(::DummyBigInt) = true
3435
LinearAlgebra.hermitian_type(::Type{DummyBigInt}) = DummyBigInt
3536
LinearAlgebra.hermitian(x::DummyBigInt, ::Symbol) = x
3637
LinearAlgebra.dot(x::DummyBigInt, y::DummyBigInt) = x * y

test/matmul.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,13 @@ end
205205
alloc_test(() -> MA.mutability(y, MA.add_mul, y, A, x), 0)
206206
end
207207

208-
# 40 bytes to create the buffer
209-
# 8 bytes in the double for loop. FIXME: figure out why
210-
# Half size on 32-bit.
211-
n = Sys.WORD_SIZE == 64 ? 48 : 24
212-
alloc_test(() -> MA.add_mul!!(y, A, x), n)
208+
alloc_test(() -> MA.add_mul!!(y, A, x), BIGINT_ALLOC)
213209
alloc_test(
214210
() -> MA.operate_fallback!!(MA.IsMutable(), MA.add_mul, y, A, x),
215-
n,
211+
BIGINT_ALLOC,
216212
)
217-
alloc_test(() -> MA.operate!!(MA.add_mul, y, A, x), n)
218-
alloc_test(() -> MA.operate!(MA.add_mul, y, A, x), n)
213+
alloc_test(() -> MA.operate!!(MA.add_mul, y, A, x), BIGINT_ALLOC)
214+
alloc_test(() -> MA.operate!(MA.add_mul, y, A, x), BIGINT_ALLOC)
219215
# Apparently, all allocations were on creating the buffer since this is allocation free:
220216
buffer = MA.buffer_for(MA.add_mul, typeof(y), typeof(A), typeof(x))
221217
alloc_test(() -> MA.buffered_operate!(buffer, MA.add_mul, y, A, x), 0)

test/utilities.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66

77
include("dummy.jl")
88

9-
# Allocating size for allocating a `BigInt`.
10-
# Half size on 32-bit.
11-
const BIGINT_ALLOC = Sys.WORD_SIZE == 64 ? 48 : 24
9+
# Allocating size for allocating a `BigInt`. Half size on 32-bit.
10+
const BIGINT_ALLOC = @static if VERSION >= v"1.12"
11+
Sys.WORD_SIZE == 64 ? 72 : 36
12+
elseif VERSION >= v"1.11"
13+
Sys.WORD_SIZE == 64 ? 56 : 28
14+
else
15+
Sys.WORD_SIZE == 64 ? 48 : 24
16+
end
1217

1318
function alloc_test(f, n)
1419
f() # compile

0 commit comments

Comments
 (0)