|
139 | 139 | @test u1.u[2] isa SVector |
140 | 140 | end |
141 | 141 |
|
| 142 | +# Test recursivefill! with immutable StaticArrays (issue #461) |
| 143 | +@testset "recursivefill! with immutable StaticArrays (issue #461)" begin |
| 144 | + # Test with only immutable SVectors |
| 145 | + x = VectorOfArray([SVector{2}(ones(2)), SVector{2}(ones(2))]) |
| 146 | + recursivefill!(x, 0.0) |
| 147 | + @test all(x.u[i] == SVector{2}(zeros(2)) for i in 1:2) |
| 148 | + @test all(x.u[i] isa SVector for i in 1:2) |
| 149 | + |
| 150 | + # Test with mixed immutable and mutable StaticArrays |
| 151 | + x = VectorOfArray([SVector{2}(ones(2)), MVector{2}(ones(2))]) |
| 152 | + recursivefill!(x, 0.0) |
| 153 | + @test all(x.u[i] == [0.0, 0.0] for i in 1:2) |
| 154 | + @test x.u[1] isa SVector |
| 155 | + @test x.u[2] isa MVector |
| 156 | + |
| 157 | + # Test fill! on VectorOfArray with immutable SVectors |
| 158 | + x = VectorOfArray([SVector{2}(ones(2)), SVector{2}(ones(2))]) |
| 159 | + fill!(x, 0.0) |
| 160 | + @test all(x.u[i] == SVector{2}(zeros(2)) for i in 1:2) |
| 161 | + @test all(x.u[i] isa SVector for i in 1:2) |
| 162 | + |
| 163 | + # Test fill! on VectorOfArray with mixed types |
| 164 | + x = VectorOfArray([SVector{2}(ones(2)), MVector{2}(ones(2))]) |
| 165 | + fill!(x, 0.0) |
| 166 | + @test all(x.u[i] == [0.0, 0.0] for i in 1:2) |
| 167 | + @test x.u[1] isa SVector |
| 168 | + @test x.u[2] isa MVector |
| 169 | +end |
| 170 | + |
142 | 171 | import KernelAbstractions: get_backend |
143 | 172 | @testset "KernelAbstractions" begin |
144 | 173 | v = VectorOfArray([randn(2) for i in 1:10]) |
|
0 commit comments