1
1
@testsuite " broadcasting" (AT, eltypes)-> begin
2
2
broadcasting (AT, eltypes)
3
3
vec3 (AT, eltypes)
4
+ unknown_wrapper (AT, eltypes)
4
5
5
6
@testset " type instabilities" begin
6
7
f (x) = x ? 1.0 : 0
@@ -205,3 +206,22 @@ function vec3(AT, eltypes)
205
206
@test all (map ((a,b)-> all ((1 ,2 ,3 ) .≈ (1 ,2 ,3 )), Array (res2), res2c))
206
207
end
207
208
end
209
+
210
+ struct WrapArray{T,N,P<: AbstractArray{T,N} } <: AbstractArray{T,N}
211
+ data:: P
212
+ end
213
+ Base. @propagate_inbounds Base. getindex (A:: WrapArray , i:: Integer... ) = A. data[i... ]
214
+ Base. @propagate_inbounds Base. setindex! (A:: WrapArray , v:: Any , i:: Integer... ) = setindex! (A. data, v, i... )
215
+ Base. size (A:: WrapArray ) = size (A. data)
216
+ Broadcast. BroadcastStyle (:: Type{WrapArray{T,N,P}} ) where {T,N,P} = Broadcast. BroadcastStyle (P)
217
+ function unknown_wrapper (AT, eltypes)
218
+ @views for ET in eltypes
219
+ A = AT (randn (ET, 10 , 10 ))
220
+ WA = WrapArray (A)
221
+ @test Array (WA .+ WA) == Array (WA .+ A) == Array (A .+ A)
222
+ @test Array (WA .+ A[:,1 ]) == Array (A .+ A[:,1 ])
223
+ @test Array (WA .+ A[1 ,:]) == Array (A .+ A[1 ,:])
224
+ WA .= ET (1 ) # test for dispatch with dest's BroadcastStyle.
225
+ @test all (isequal (ET (1 )), Array (A))
226
+ end
227
+ end
0 commit comments