Skip to content

Commit 7c0d397

Browse files
committed
Fix and test for ambiguities on 0.6
1 parent 99faf1f commit 7c0d397

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/RoundingIntegers.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Base.promote_rule{T<:Real,RI<:RInteger}(::Type{Complex{T}}, ::Type{RI}) =
7777
promote_type(Complex{T}, itype(RI))
7878
Base.promote_rule{T<:Integer,RI<:RInteger}(::Type{Rational{T}}, ::Type{RI}) =
7979
promote_type(Rational{T}, itype(RI))
80-
Base.promote_rule{s,RI<:RInteger}(::Type{Irrational{s}}, ::Type{RI}) =
81-
promote_type(Irrational{S}, itype(RI))
80+
@compat Base.promote_rule{RI<:RInteger}(::Type{<:Irrational}, ::Type{RI}) =
81+
promote_type(Float64, itype(RI))
8282

8383
(::Type{Signed})(x::RSigned) = reinterpret(itype(x), x)
8484
(::Type{Unsigned})(x::RUnsigned) = reinterpret(itype(x), x)
@@ -90,8 +90,9 @@ Base.promote_rule{s,RI<:RInteger}(::Type{Irrational{s}}, ::Type{RI}) =
9090
(::Type{RInteger})(x::Unsigned) = RUnsigned(x)
9191

9292
# Basic conversions
93-
@inline Base.convert{T<:RSigned}(::Type{T}, x::T) = x
94-
@inline Base.convert{T<:RUnsigned}(::Type{T}, x::T) = x
93+
# @inline Base.convert{T<:RSigned}(::Type{T}, x::T) = x
94+
# @inline Base.convert{T<:RUnsigned}(::Type{T}, x::T) = x
95+
@inline Base.convert{T<:RInteger}(::Type{T}, x::T) = x
9596
@inline Base.convert{T<:RInteger}(::Type{T}, x::RInteger) =
9697
RInteger(convert(itype(T), Integer(x)))
9798
@inline Base.convert{T<:RInteger}(::Type{T}, x::Integer) = RInteger(convert(itype(T), x))
@@ -120,6 +121,7 @@ Base.convert{T<:RInteger}(::Type{T}, x::Float16) = RInteger(convert(itype(T), x)
120121
Base.convert(::Type{Bool}, x::RInteger) = convert(Bool, Integer(x))
121122

122123
# rem conversions
124+
@inline Base.rem{T<:RInteger}(x::T, ::Type{T}) = T
123125
@inline Base.rem{T<:RInteger}(x::Integer, ::Type{T}) = RInteger(rem(x, itype(T)))
124126
# ambs
125127
@inline Base.rem{T<:RInteger}(x::BigInt, ::Type{T}) = error("no rounding BigInt available")

test/runtests.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
using RoundingIntegers
21
using Compat, Base.Test
3-
4-
@test isempty(detect_ambiguities(Base, Core, RoundingIntegers))
2+
if VERSION < v"0.6.0-pre.alpha.229"
3+
using RoundingIntegers
4+
@test isempty(detect_ambiguities(Base, Core, RoundingIntegers))
5+
else
6+
ambs0 = detect_ambiguities(Base, Core, Compat)
7+
using RoundingIntegers
8+
ambs1 = detect_ambiguities(Base, Core, Compat, RoundingIntegers)
9+
@test isempty(setdiff(ambs1, ambs0))
10+
end
511

612
@testset "Basics" begin
713
r16 = RInt16(3)

0 commit comments

Comments
 (0)