Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Throw ArgumentError from copy! when n<0
Browse files Browse the repository at this point in the history
Julia 0.5 changed this, need to be consistent for tests to pass with
any type.
  • Loading branch information
nalimilan committed Jul 3, 2016
1 parent 9428f16 commit 878038e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/dataarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ function Base.copy!(dest::DataArray, doffs::Integer, src::DataArray, soffs::Inte
if n == 0
return dest
elseif n < 0
throw(BoundsError())
if VERSION >= v"0.5.0-dev+4711"
throw(ArgumentError("tried to copy n=$n elements, but n should be nonnegative"))
else
throw(BoundsError())
end
end
if isbits(eltype(src))
copy!(dest.data, doffs, src.data, soffs, n)
Expand Down
6 changes: 5 additions & 1 deletion test/dataarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ module TestDataArray
@test_throws BoundsError copy!(dest, 1, src, idx, 1)
end

@test_throws BoundsError copy!(dest, 1, src, 1, -1)
if VERSION >= v"0.5.0-dev+4711"
@test_throws ArgumentError copy!(dest, 1, src, 1, -1)
else
@test_throws BoundsError copy!(dest, 1, src, 1, -1)
end

@test_throws BoundsError copy!(dest, bigsrc)

Expand Down

0 comments on commit 878038e

Please sign in to comment.