Skip to content

Commit

Permalink
Implement upreferred(::Missing)
Browse files Browse the repository at this point in the history
  • Loading branch information
cstjean committed Apr 16, 2019
1 parent 82f8496 commit 1653ab4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/user.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ units `ContextUnits(z,z)`.
"""
@inline upreferred(x::Number) = x
@inline upreferred(x::Quantity) = uconvert(upreferred(unit(x)), x)
@inline upreferred(::Missing) = missing

"""
upreferred(x::Units)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ end
@test @inferred(upreferred(1g |> ContextUnits(g,mg))) == 1000mg

@test @inferred(upreferred(1N)) === (1//1)*kg*m/s^2
@test ismissing(upreferred(missing))
end
@testset "> promote_unit" begin
@test Unitful.promote_unit(FreeUnits(m)) === FreeUnits(m)
Expand Down

0 comments on commit 1653ab4

Please sign in to comment.