Skip to content

Commit

Permalink
A few missing AbstractArray tests (JuliaLang#38806)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and ElOceanografo committed May 4, 2021
1 parent fefed9d commit f3f4594
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,24 @@ function test_cat(::Type{TestAbstractArray})
b_int = reshape([1:27...], 3, 3, 3)
b_float = reshape(Float64[1:27...], 3, 3, 3)
b2hcat = Array{Float64}(undef, 3, 6, 3)
b2vcat = Array{Float64}(undef, 6, 3, 3)
b1 = reshape([1:9...], 3, 3)
b2 = reshape([10:18...], 3, 3)
b3 = reshape([19:27...], 3, 3)
b2hcat[:, :, 1] = hcat(b1, b1)
b2hcat[:, :, 2] = hcat(b2, b2)
b2hcat[:, :, 3] = hcat(b3, b3)
b2vcat[:, :, 1] = vcat(b1, b1)
b2vcat[:, :, 2] = vcat(b2, b2)
b2vcat[:, :, 3] = vcat(b3, b3)
b3hcat = Array{Float64}(undef, 3, 9, 3)
b3hcat[:, :, 1] = hcat(b1, b1, b1)
b3hcat[:, :, 2] = hcat(b2, b2, b2)
b3hcat[:, :, 3] = hcat(b3, b3, b3)
b3vcat = Array{Float64}(undef, 9, 3, 3)
b3vcat[:, :, 1] = vcat(b1, b1, b1)
b3vcat[:, :, 2] = vcat(b2, b2, b2)
b3vcat[:, :, 3] = vcat(b3, b3, b3)
B = TSlow(b_int)
B1 = TSlow([1:24...])
B2 = TSlow([1:25...])
Expand All @@ -625,14 +633,20 @@ function test_cat(::Type{TestAbstractArray})
i = rand(1:10)

@test cat(;dims=i) == Any[]
@test Base.typed_hcat(Float64) == Vector{Float64}()
@test Base.typed_vcat(Float64) == Vector{Float64}()
@test vcat() == Any[]
@test hcat() == Any[]
@test vcat(1, 1.0, 3, 3.0) == [1.0, 1.0, 3.0, 3.0]
@test hcat(1, 1.0, 3, 3.0) == [1.0 1.0 3.0 3.0]
@test_throws ArgumentError hcat(B1, B2)
@test_throws ArgumentError vcat(C1, C2)

@test vcat(B) == B
@test hcat(B) == B
@test Base.typed_vcat(Float64, B) == TSlow(b_float)
@test Base.typed_vcat(Float64, B, B) == TSlow(b2vcat)
@test Base.typed_vcat(Float64, B, B, B) == TSlow(b3vcat)
@test Base.typed_hcat(Float64, B) == TSlow(b_float)
@test Base.typed_hcat(Float64, B, B) == TSlow(b2hcat)
@test Base.typed_hcat(Float64, B, B, B) == TSlow(b3hcat)
Expand Down

0 comments on commit f3f4594

Please sign in to comment.