Skip to content

Commit

Permalink
Test that similar throws a MethodError for unsupported dims types
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Aug 18, 2016
1 parent ac0367b commit d82a822
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/offsetarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ B = similar(A, (-3:3,1:4))
B = similar(parent(A), (-3:3,1:4))
@test isa(B, OffsetArray{Int,2})
@test indices(B) === (-3:3, 1:4)
# Check that similar throws a MethodError rather than a
# StackOverflowError if no appropriate method has been defined
# (#18107)
module SimilarUR
immutable MyURange <: AbstractUnitRange{Int}
start::Int
stop::Int
end
ur = MyURange(1,3)
a = Array{Int}(2)
@test_throws MethodError similar(a, ur)
@test_throws MethodError similar(a, Float64, ur)
@test_throws MethodError similar(a, Float64, (ur,))
@test_throws MethodError similar(a, (2.0,3.0))
end

# Indexing with OffsetArray indices
i1 = OffsetArray([2,1], (-5,))
Expand Down

0 comments on commit d82a822

Please sign in to comment.