Skip to content

Commit

Permalink
fix #35225, issubset on empty ranges (#35244)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet authored and KristofferC committed Apr 11, 2020
1 parent c8d277f commit 797f769
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ end
issubset(r::OneTo, s::OneTo) = r.stop <= s.stop

issubset(r::AbstractUnitRange{<:Integer}, s::AbstractUnitRange{<:Integer}) =
first(r) >= first(s) && last(r) <= last(s)
isempty(r) || first(r) >= first(s) && last(r) <= last(s)

## linear operations on ranges ##

Expand Down
5 changes: 5 additions & 0 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ end
@test !issubset(Base.OneTo(10), Base.OneTo(5))
@test issubset(1:3:10, 1:10)
@test !issubset(1:10, 1:3:10)
# with empty ranges
@test issubset(2:1, 3:4) #35225
@test issubset(2:1, 3:2)
@test issubset(Base.OneTo(0), Base.OneTo(3))
@test issubset(Base.OneTo(0), Base.OneTo(-3))
end
@testset "sort/sort!/partialsort" begin
@test sort(UnitRange(1,2)) == UnitRange(1,2)
Expand Down

0 comments on commit 797f769

Please sign in to comment.