diff --git a/src/IntervalSets.jl b/src/IntervalSets.jl index 84a5124..fc689c4 100644 --- a/src/IntervalSets.jl +++ b/src/IntervalSets.jl @@ -3,7 +3,7 @@ __precompile__() module IntervalSets using Base: @pure -import Base: eltype, convert, show, in, length, isempty, isequal, issubset, ==, hash, +import Base: eltype, convert, show, in, length, isempty, isequal, isless, issubset, ==, hash, union, intersect, minimum, maximum, extrema, range, ⊇ using Compat diff --git a/src/closed.jl b/src/closed.jl index d1d5d94..1bd6abe 100644 --- a/src/closed.jl +++ b/src/closed.jl @@ -43,7 +43,9 @@ in(a::ClosedInterval, b::ClosedInterval) = (b.left <= a.left) & (a.right <= b.ri isempty(A::ClosedInterval) = A.left > A.right -isequal(A::ClosedInterval, B::ClosedInterval) = (isequal(A.left, B.left) & isequal(A.right, B.right)) | (isempty(A) & isempty(B)) +isequal(A::ClosedInterval, B::ClosedInterval) = isequal(A.left, B.left) & isequal(A.right, B.right) + +isless(A::ClosedInterval, B::ClosedInterval) = isless(A.left, B.left) | (isequal(A.left, B.left) & isless(A.right, B.right)) ==(A::ClosedInterval, B::ClosedInterval) = (A.left == B.left && A.right == B.right) || (isempty(A) && isempty(B)) diff --git a/test/runtests.jl b/test/runtests.jl index 3873f3e..fb1b68c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -41,7 +41,11 @@ using Compat.Dates @test J == J @test L == L @test isequal(I, I) - @test isequal(J, K) + @test !isequal(J, K) + @test !isless(I, I) + @test isless(I, J) + @test !isless(J, I) + @test isless(I, 0..4) @test typeof(M.left) == typeof(M.right) && typeof(M.left) == Float64 @test typeof(N.left) == typeof(N.right) && typeof(N.left) == Int