diff --git a/.travis.yml b/.travis.yml index f389d86..c1ac57e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ os: - linux - osx julia: + - 0.6 - 0.7 - nightly notifications: diff --git a/REQUIRE b/REQUIRE index 859ad46..137767a 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1 +1 @@ -julia 0.7 +julia 0.6 diff --git a/src/Zeros.jl b/src/Zeros.jl index 3616b43..a334c4b 100644 --- a/src/Zeros.jl +++ b/src/Zeros.jl @@ -12,7 +12,6 @@ export Zero, testzero, zero! struct Zero <: Integer end -Zero(x::Number) = iszero(x) ? Zero() : throw(InexactError(:Zero, Zero, x)) promote_rule(::Type{Zero}, ::Type{T}) where {T<:Number} = T promote_rule(::Type{Zero}, ::Type{Zero}) = Float64 @@ -21,6 +20,19 @@ convert(::Type{Zero}, ::Zero) = Zero() convert(::Type{T}, ::Zero) where {T<:Number} = zero(T) convert(::Type{Zero}, x::T) where {T<:Number} = Zero(x) +if VERSION < v"0.7-" + Zero(x::Number) = iszero(x) ? Zero() : throw(InexactError()) + + # Disambiguation needed for Julia 0.6 + convert(::Type{T}, ::Zero) where {T<:Real} = zero(T) + convert(::Type{BigInt}, ::Zero) = zero(BigInt) + convert(::Type{BigFloat}, ::Zero) = zero(BigFloat) + convert(::Type{Float16}, ::Zero) = zero(Float16) + convert(::Type{Complex{T}}, ::Zero) where {T<:Real} = zero(Complex{T}) +else + Zero(x::Number) = iszero(x) ? Zero() : throw(InexactError(:Zero, Zero, x)) +end + AbstractFloat(::Zero) = 0.0 Complex(x::Real, ::Zero) = x diff --git a/test/runtests.jl b/test/runtests.jl index e8604d6..dc25ca8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,9 @@ using Zeros -using Test +if VERSION < v"0.7-" + using Base.Test +else + using Test +end # Real Z = Zero()