Skip to content

Commit 904d103

Browse files
committed
Compare constructor behavior against Base.Array.
1 parent cf6c2e1 commit 904d103

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/testsuite/construction.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,34 @@ function constructors(AT)
6161
@test eltype(B) == T
6262
end
6363
end
64+
@testset "comparison against Array" begin
65+
for typs in [(), (Int,), (Int,1), (Int,2), (Float32,), (Float32,1), (Float32,2)],
66+
args in [(), (1,), (1,2), ((1,),), ((1,2),),
67+
(undef,), (undef, 1,), (undef, 1,2), (undef, (1,),), (undef, (1,2),),
68+
(Int,), (Int, 1,), (Int, 1,2), (Int, (1,),), (Int, (1,2),),
69+
([1,2],), ([1 2],)]
70+
cpu = try
71+
Array{typs...}(args...)
72+
catch ex
73+
isa(ex, MethodError) || rethrow()
74+
nothing
75+
end
76+
77+
gpu = try
78+
AT{typs...}(args...)
79+
catch ex
80+
isa(ex, MethodError) || rethrow()
81+
cpu == nothing || rethrow()
82+
nothing
83+
end
84+
85+
if cpu == nothing
86+
@test gpu == nothing
87+
else
88+
@test typeof(cpu) == typeof(convert(Array, gpu))
89+
end
90+
end
91+
end
6492
end
6593

6694
function conversion(AT)

0 commit comments

Comments
 (0)