Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #35225, issubset on empty ranges #35244

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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