Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few missing indices tests #31706

Merged
merged 2 commits into from
Apr 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -970,3 +970,20 @@ end
@test get(11:15, CartesianIndex(6), nothing) === nothing
@test get(11:15, CartesianIndex(5), nothing) === 15
end

@testset "IndexStyle for various types" begin
@test Base.IndexStyle(UpperTriangular) == IndexCartesian() # subtype of AbstractArray, not of Array
@test Base.IndexStyle(Vector) == IndexLinear()
@test Base.IndexStyle(UnitRange) == IndexLinear()
@test Base.IndexStyle(UpperTriangular(rand(3, 3)), [1; 2; 3]) == IndexCartesian()
@test Base.IndexStyle(UpperTriangular(rand(3, 3)), rand(3, 3), [1; 2; 3]) == IndexCartesian()
@test Base.IndexStyle(rand(3, 3), [1; 2; 3]) == IndexLinear()
end

@testset "promote_shape for Tuples and Dims" begin
@test promote_shape((2, 1), (2,)) == (2, 1)
@test_throws DimensionMismatch promote_shape((2, 3), (2,))
@test promote_shape(Dims((2, 1)), Dims((2,))) == (2, 1)
@test_throws DimensionMismatch promote_shape(Dims((2, 2)), Dims((2,)))
@test_throws DimensionMismatch promote_shape(Dims((2, 3, 1)), Dims((2,2)))
end