diff --git a/src/disambiguities.jl b/src/disambiguities.jl index 7d822b91..6387ca83 100644 --- a/src/disambiguities.jl +++ b/src/disambiguities.jl @@ -1,9 +1,17 @@ -for op in (:isless, :(==), :isequal, :(<)), (type, _, _) in ABSTRACT_QUANTITY_TYPES +for op in (:(==), :(<)), (type, _, _) in ABSTRACT_QUANTITY_TYPES @eval begin Base.$(op)(::$type, ::Missing) = missing Base.$(op)(::Missing, ::$type) = missing end end +for (type, _, _) in ABSTRACT_QUANTITY_TYPES + @eval begin + Base.isequal(::$type, ::Missing) = false + Base.isequal(::Missing, ::$type) = false + Base.isless(::$type, ::Missing) = true + Base.isless(::Missing, ::$type) = false + end +end for op in (:isapprox,), (type, _, _) in ABSTRACT_QUANTITY_TYPES @eval begin Base.$(op)(::$type, ::Missing; kws...) = missing diff --git a/test/unittests.jl b/test/unittests.jl index 9f2ee5e5..4fc0c3fc 100644 --- a/test/unittests.jl +++ b/test/unittests.jl @@ -1165,8 +1165,8 @@ end @test round(Union{Int32,Missing}, FixedRational{Int32,100}(1)) isa Int32 @test round(Union{Int32,Missing}, FixedRational{Int32,100}(1)) === Int32(1) y = missing - @test isless(x, y) === missing - @test isless(y, x) === missing + @test (x < y) === missing + @test (y < x) === missing @test (x == y) === missing @test (y == x) === missing @test isapprox(x, y) === missing @@ -1176,6 +1176,15 @@ end y = missing @test x * y === missing @test x + y === missing + + @testset "$(typeof(q))" for q in (1.0u"m", 1.0us"mg", RealQuantity(1.0u"m"), GenericQuantity(1.0u"m")) + @test isequal(q, missing) === false + @test isequal(missing, q) === false + @test isless(q, missing) === true + @test isless(missing, q) === false + @test isequal(sort([missing, 2q, q]), [q, 2q, missing]) + @test findfirst(isequal(missing), [q, missing]) == 2 + end end