Skip to content

Commit

Permalink
Merge pull request #29 from JuliaAlgebra/bl/unbroken_+
Browse files Browse the repository at this point in the history
Unbreak broken tests
  • Loading branch information
kalmarek authored Apr 24, 2024
2 parents feca94e + 719b7b9 commit ce2a672
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions test/caching_allocations.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# `@allocations` is not defined on Julia v1.6
@static if v"1.10" VERSION
function _alloc_test(output, op, a, b, allocs)
MA.operate_to!(output, op, a, b)
expected = op(a, b)
@test @allocations(MA.operate_to!(output, op, a, b)) <= allocs
@test output == expected
end
end

@testset "FixedBasis caching && allocations" begin
alph = [:a, :b, :c]
A★ = FreeWords(alph)
Expand All @@ -11,7 +21,7 @@
y = spzeros(length(basis(fRG)))
y[1:k] .= 1
Y = AlgebraElement(y, fRG)
@test_broken Y = sum(fRG(basis(fRG)[i]) for i in 1:k)
@test Y == sum(fRG(basis(fRG)[i]) for i in 1:k)

@test Y isa AlgebraElement

Expand Down Expand Up @@ -44,23 +54,10 @@

@static if v"1.10" VERSION < v"1.11"
YY = deepcopy(Y)

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

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

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

# MA.operate_to!(YY, +, Y, Y)
@test_broken @allocations(MA.operate_to!(YY, +, Y, Y)) == 0
@test_broken YY == Y + Y
_alloc_test(YY, *, Y, Y, 25)
_alloc_test(YY, +, Y, Y, 0)
# SparseArrays calls `Base.unalias` which allocates
_alloc_test(YY, +, YY, Y, 2)
_alloc_test(YY, +, Y, YY, 2)
end
end

0 comments on commit ce2a672

Please sign in to comment.