Skip to content

Commit

Permalink
Fix #7426
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Jun 29, 2014
1 parent e460d50 commit ddb0478
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ similar(r::Range, T::Type, dims::Dims) = Array(T, dims)
size(r::Range) = (length(r),)

isempty(r::StepRange) =
(r.start != r.stop) && ((r.step > zero(r.step)) != (r.stop > r.start))
(r.start != r.stop) & ((r.step > zero(r.step)) != (r.stop > r.start))
isempty(r::UnitRange) = r.start > r.stop
isempty(r::FloatRange) = length(r)==0

Expand Down Expand Up @@ -224,7 +224,8 @@ done(r::FloatRange, i) = (length(r) <= i)
# lifted domain (e.g. Int8+Int8 => Int); use that for iterating.
start(r::StepRange) = convert(typeof(r.start+r.step), r.start)
next{T}(r::StepRange{T}, i) = (oftype(T,i), i+r.step)
done{T,S}(r::StepRange{T,S}, i) = (i!=r.stop) & ((r.step>zero(S))==(i>r.stop))
done{T,S}(r::StepRange{T,S}, i) = isempty(r) | (i < min(r.start, r.stop)) | (i > max(r.start, r.stop))
done{T,S}(r::StepRange{T,S}, i::Integer) = isempty(r) | (i == r.stop+r.step)

start(r::UnitRange) = oftype(r.start+1, r.start)
next{T}(r::UnitRange{T}, i) = (oftype(T,i), i+1)
Expand Down
2 changes: 2 additions & 0 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,5 @@ r = linrange(0.25,0.25,1)
@test length(r) == 1
@test_throws Exception linrange(0.25,0.5,1)

# issue #7426
@test [typemax(Int):1:typemax(Int)] == [typemax(Int)]

0 comments on commit ddb0478

Please sign in to comment.