Skip to content

Commit

Permalink
Add ifelse broadcast test
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Jun 27, 2023
1 parent 54fd09e commit a7201d2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/Fields/field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,27 @@ end
end
end

function ifelse_wrapper(a, b)
@. a.x = ifelse(a.x < b.x, 1, 2)
return nothing
end

@testset "Broadcasting ifelse" begin
FT = Float32
for space in TU.all_spaces(FT)
f = fill((; x = FT(1)), space)
g = fill((; x = FT(2)), space)
ifelse_wrapper(f, g) # Compile first
p_allocated = @allocated ifelse_wrapper(f, g)
if space isa Spaces.SpectralElementSpace1D
@test p_allocated == 0
else
@test_broken p_allocated == 0

end
end
end

# Requires `--check-bounds=yes`
@testset "Constructing & broadcasting over empty fields" begin
FT = Float32
Expand Down

0 comments on commit a7201d2

Please sign in to comment.