File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 777
777
function intersect (r:: StepRange , s:: StepRange )
778
778
if isempty (r) || isempty (s)
779
779
return range (first (r), step= step (r), length= 0 )
780
- elseif step (s) < 0
780
+ elseif step (s) < zero ( step (s))
781
781
return intersect (r, reverse (s))
782
- elseif step (r) < 0
782
+ elseif step (r) < zero ( step (r))
783
783
return reverse (intersect (reverse (r), s))
784
784
end
785
785
@@ -804,7 +804,7 @@ function intersect(r::StepRange, s::StepRange)
804
804
805
805
g, x, y = gcdx (step1, step2)
806
806
807
- if rem (start1 - start2, g) != 0
807
+ if ! iszero ( rem (start1 - start2, g))
808
808
# Unaligned, no overlap possible.
809
809
return range (start1, step= a, length= 0 )
810
810
end
Original file line number Diff line number Diff line change 361
361
362
362
@test intersect (1 : 3 , 2 ) === intersect (2 , 1 : 3 ) === 2 : 2
363
363
@test intersect (1.0 : 3.0 , 2 ) == intersect (2 , 1.0 : 3.0 ) == [2.0 ]
364
+
365
+ @testset " Support StepRange with a non-numeric step" begin
366
+ start = Date (1914 , 7 , 28 )
367
+ stop = Date (1918 , 11 , 11 )
368
+
369
+ @test intersect (start: Day (1 ): stop, start: Day (1 ): stop) == start: Day (1 ): stop
370
+ @test intersect (start: Day (1 ): stop, start: Day (5 ): stop) == start: Day (5 ): stop
371
+ @test intersect (start- Day (10 ): Day (1 ): stop- Day (10 ), start: Day (5 ): stop) ==
372
+ start: Day (5 ): stop- Day (10 )- mod (stop- start, Day (5 ))
373
+ end
364
374
end
365
375
@testset " issubset" begin
366
376
@test issubset (1 : 3 , 1 : typemax (Int)) # 32461
You can’t perform that action at this time.
0 commit comments