Skip to content

Commit 7cfc55f

Browse files
authored
Add test to detect allocations during broadcasting (#73)
* Add test to detect allocations during broadcasting Mainly to prevent a regression. * small changes * forgot function renaming
1 parent 95d96b1 commit 7cfc55f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/broadcast.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,21 @@ Broadcast.broadcastable(x::ScalarTest) = Ref(x)
190190
d = HybridVector{4}([1, 2, 3, 4])
191191
@test_throws DimensionMismatch a .= d
192192
end
193+
194+
@testset "no allocations during broadcasting" begin
195+
# HybridArrays issue #64
196+
# Fixed in Julia 1.11
197+
function test_broadcast_allocs()
198+
H = HybridArray{Tuple{2,2,StaticArrays.Dynamic()}}(randn(2,2,2))
199+
H2 = HybridArray{Tuple{2,2,StaticArrays.Dynamic()}}(Array{Float64}(undef, 2, 2, 4))
200+
@allocated H2[:,:,1:2] .= H
201+
end
202+
203+
if VERSION >= v"1.11"
204+
@test test_broadcast_allocs() == 0
205+
else
206+
@test_broken test_broadcast_allocs() == 0
207+
end
208+
end
209+
193210
end

0 commit comments

Comments
 (0)