Skip to content

Commit

Permalink
range tests: allow any range length that hits stop (#20532)
Browse files Browse the repository at this point in the history
This test was occasionally failing (~1 in 10 million times) since
there are cases where the length of such a range is ambiguous, i.e.
there is more than one `n` such that `start + (n-1)*step == stop`.
This adjusts the test to allow any such choice of range length.
  • Loading branch information
StefanKarpinski committed Feb 9, 2017
1 parent e24faa5 commit b7ad743
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,13 @@ end

for T = (Float32, Float64,), i = 1:2^15, n = 1:5
start, step = randn(T), randn(T)
step == 0 && continue
stop = start + (n-1)*step
lo = hi = n
while start + (lo-1)*step == stop; lo -= 1; end
while start + (hi-1)*step == stop; hi += 1; end
r = start:step:stop
@test n == length(r)
@test lo < length(r) < hi
# FIXME: these fail some small portion of the time
@test_skip start == first(r)
@test_skip stop == last(r)
Expand Down

0 comments on commit b7ad743

Please sign in to comment.