Skip to content
Open
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
10 changes: 9 additions & 1 deletion src/disambiguities.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 11 additions & 2 deletions test/unittests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
Loading