Skip to content

Commit

Permalink
Added test for modifying a tuple element using setindex (#34857)
Browse files Browse the repository at this point in the history
  • Loading branch information
ravibitsgoa authored and KristofferC committed Apr 11, 2020
1 parent b8c38c3 commit 06714fe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,18 @@ end

# tuple_type_tail on non-normalized vararg tuple
@test Base.tuple_type_tail(Tuple{Vararg{T, 3}} where T<:Real) == Tuple{Vararg{T, 2}} where T<:Real

@testset "setindex" begin
@test Base.setindex((1, ), 2, 1) === (2, )
@test Base.setindex((1, 2), 3, 1) === (3, 2)
@test_throws BoundsError Base.setindex((), 1, 1)
@test_throws BoundsError Base.setindex((1, ), 2, 2)
@test_throws BoundsError Base.setindex((1, 2), 2, 0)
@test_throws BoundsError Base.setindex((1, 2, 3), 2, -1)

@test_throws BoundsError Base.setindex((1, 2), 2, 3)
@test_throws BoundsError Base.setindex((1, 2), 2, 4)

@test Base.setindex((1, 2, 4), 4, true) === (4, 2, 4)
@test_throws BoundsError Base.setindex((1, 2), 2, false)
end

0 comments on commit 06714fe

Please sign in to comment.