Skip to content

Commit

Permalink
[tests] fix: @Allocations exist in julia ≥ 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Apr 2, 2024
1 parent 18a74d8 commit 1632be4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
SparseArrays = "1"
MutableArithmetics = "1"
SparseArrays = "1"
julia = "1.6"
48 changes: 29 additions & 19 deletions test/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ end
end
end
@testset "mutable arithmetic" begin

a = let l = 12, R = 7
support = [Word(alph, rand(1:length(alph), rand(0:R))) for _ in 1:l]
vals = rand(-3:3, l)
Expand Down Expand Up @@ -292,9 +291,11 @@ end

@test Y isa AlgebraElement

star(Y)
star(Y)
@test (@allocations star(Y)) 4
@static if VERSION v"1.9"
star(Y)
star(Y)
@test (@allocations star(Y)) 4
end

@test supp(Y) == basis(fRG)[1:k]

Expand All @@ -303,26 +304,35 @@ end

@test_throws SA.UndefRefError all(!iszero, SA.mstructure(fRG).table)

@test (@allocations Y * Y) > k^2 - 2 * k

@test Y * Y isa AlgebraElement
@static if VERSION v"1.9"
@test (@allocations Y * Y) > k^2 - 2 * k
@test Y * Y isa AlgebraElement
@test (@allocations Y * Y) < 50
else
k1 = @allocated Y * Y
@test Y * Y isa AlgebraElement
Y * Y
k2 = @allocated Y * Y
@test k2 / k1 < 0.2
end

@test all(!iszero, SA.mstructure(fRG).table)

@test (@allocations Y * Y) < 50

YY = deepcopy(Y)
@test_broken @allocations(MA.operate_to!(YY, +, Y, YY)) == 0
@test_broken YY == Y + Y
@static if VERSION v"1.9"
YY = deepcopy(Y)
@test_broken @allocations(MA.operate_to!(YY, +, Y, YY)) == 0
@test_broken YY == Y + Y

YY = deepcopy(Y)
@test_broken @allocations(MA.operate_to!(YY, +, YY, Y)) == 0
@test_broken YY == Y + Y
YY = deepcopy(Y)
@test_broken @allocations(MA.operate_to!(YY, +, YY, Y)) == 0
@test_broken YY == Y + Y

@test_broken @allocations(MA.operate_to!(YY, +, Y, deepcopy(Y))) == 0
@test_broken YY == Y + Y
@test_broken @allocations(MA.operate_to!(YY, +, Y, deepcopy(Y))) ==
0
@test_broken YY == Y + Y

@test @allocations(MA.operate_to!(YY, *, Y, Y)) 40
@test YY == Y * Y
@test @allocations(MA.operate_to!(YY, *, Y, Y)) 40
@test YY == Y * Y
end
end
end

0 comments on commit 1632be4

Please sign in to comment.