From 0a85747d7a5a931ef3259dea930e1aa1f2f1f0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 24 Apr 2024 09:29:14 +0200 Subject: [PATCH 1/3] Unbreak broken tests --- test/caching_allocations.jl | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/test/caching_allocations.jl b/test/caching_allocations.jl index 0af4adf..f63d0a5 100644 --- a/test/caching_allocations.jl +++ b/test/caching_allocations.jl @@ -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) @@ -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 @@ -42,25 +52,12 @@ @test all(!iszero, SA.mstructure(fRG).table) - @static if v"1.10" ≤ VERSION < v"1.11" + @static if v"1.10" ≤ VERSION 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 +end \ No newline at end of file From 53a308d8e47dc2e69fabee922137bd98be67563a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 24 Apr 2024 10:11:30 +0200 Subject: [PATCH 2/3] Exclude on Julia latest --- test/caching_allocations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/caching_allocations.jl b/test/caching_allocations.jl index f63d0a5..fb7eaa4 100644 --- a/test/caching_allocations.jl +++ b/test/caching_allocations.jl @@ -52,7 +52,7 @@ end @test all(!iszero, SA.mstructure(fRG).table) - @static if v"1.10" ≤ VERSION + @static if v"1.10" ≤ VERSION < v"1.11" YY = deepcopy(Y) _alloc_test(YY, *, Y, Y, 25) _alloc_test(YY, +, Y, Y, 0) From 719b7b9038adcd19c1968ef718d3e51ec45414d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 24 Apr 2024 10:13:09 +0200 Subject: [PATCH 3/3] Missing newline --- test/caching_allocations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/caching_allocations.jl b/test/caching_allocations.jl index fb7eaa4..5ba22ac 100644 --- a/test/caching_allocations.jl +++ b/test/caching_allocations.jl @@ -60,4 +60,4 @@ end _alloc_test(YY, +, YY, Y, 2) _alloc_test(YY, +, Y, YY, 2) end -end \ No newline at end of file +end