Skip to content

Commit 08c0398

Browse files
committed
Fix ambiguity test of SignedMultiplicativeInverse
1 parent a66ec1d commit 08c0398

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/disambiguities.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ Base.:/(l::AbstractDimensions, r::Number) = error("Please use an `UnionAbstractQ
1414
Base.:/(l::Number, r::AbstractDimensions) = error("Please use an `UnionAbstractQuantity` for division. You used division on types: $(typeof(l)) and $(typeof(r)).")
1515

1616
if VERSION < v"1.7"
17-
for I in (Base.MultiplicativeInverses.UnsignedMultiplicativeInverse, Base.MultiplicativeInverses.SignedMultiplicativeInverse)
18-
@eval function Base.div(x::T, y::$I{T}, r::RoundingMode=RoundToZero) where {T<:AbstractGenericQuantity}
19-
return new_quantity(typeof(x), div(ustrip(x), y, r), dimension(x))
20-
end
17+
@eval function Base.div(x::DynamicQuantities.AbstractGenericQuantity{T}, y::T) where {T}
18+
return new_quantity(typeof(x), div(ustrip(x), y), dimension(x))
2119
end
22-
end
20+
end

test/unittests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,16 @@ end
757757
y = x ^ (3//2)
758758
@test y == Quantity(1.0, length=3//2)
759759
@test typeof(y) == Quantity{Float64,DEFAULT_DIM_TYPE}
760+
761+
VERSION < v"1.7" && for I in (Int64, UInt64)
762+
x = GenericQuantity{I}(1u"km/s")
763+
a = (
764+
I <: Signed ?
765+
Base.MultiplicativeInverses.SignedMultiplicativeInverse :
766+
Base.MultiplicativeInverses.UnsignedMultiplicativeInverse
767+
)(I(3))
768+
@test div(x, a) == GenericQuantity{I}(333u"m/s")
769+
end
760770
end
761771

762772
for Q in (Quantity, GenericQuantity)

0 commit comments

Comments
 (0)