From d7166fc8abb4fe9d9ef00f5bfd85aa5df241aad5 Mon Sep 17 00:00:00 2001 From: quinnj Date: Tue, 19 Dec 2017 15:21:50 -0700 Subject: [PATCH] Add Compat to finally get 0.6/0.7 compat write --- REQUIRE | 1 + src/DecFP.jl | 29 ++++++++++++----------------- test/runtests.jl | 13 ++++++++++++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/REQUIRE b/REQUIRE index 90229f6..5983a3f 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,3 @@ julia 0.6 +Compat 0.40.0 BinDeps diff --git a/src/DecFP.jl b/src/DecFP.jl index ec2ca7f..b358d91 100644 --- a/src/DecFP.jl +++ b/src/DecFP.jl @@ -1,4 +1,15 @@ module DecFP + +using Compat + +if !(VERSION < v"0.7.0-DEV.3026") + using Printf +end + +if !(VERSION < v"0.7.0-DEV.2813") + using Unicode +end + export Dec32, Dec64, Dec128, @d_str, @d32_str, @d64_str, @d128_str const libbid = joinpath(dirname(@__FILE__), "..", "deps", "libbid$(Sys.WORD_SIZE)") @@ -8,22 +19,6 @@ const _buffer = fill(0x00, 1024) import Base.promote_rule import Base.Grisu.DIGITS -# https://github.com/JuliaLang/julia/pull/20005 -if VERSION < v"0.7.0-DEV.896" - Base.InexactError(name::Symbol, T, val) = InexactError() -end - -# https://github.com/JuliaLang/julia/pull/22751 -if VERSION < v"0.7.0-DEV.924" - Base.DomainError(val) = DomainError() - Base.DomainError(val, msg) = DomainError() -end - -# https://github.com/JuliaLang/julia/pull/222761 -if VERSION < v"0.7.0-DEV.1285" - Base.OverflowError(msg) = OverflowError() -end - # global pointers and dicts must be initialized at runtime (via __init__) function __init__() global const rounding = cglobal((:__bid_IDEC_glbround, libbid), Cuint) # rounding mode @@ -226,7 +221,7 @@ for w in (32,64,128) end end - for c in (:π, :e, :γ, :catalan, :φ) + for c in (:π, :e, :ℯ, :γ, :catalan, :φ) @eval begin Base.convert(::Type{$BID}, ::Irrational{$(QuoteNode(c))}) = $(_parse(T, setprecision(256) do string(BigFloat(isdefined(Base, :MathConstants) ? eval(Base.MathConstants, c) : eval(c))) diff --git a/test/runtests.jl b/test/runtests.jl index 171a27d..be34d95 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,16 @@ using DecFP -using Base.Test + +@static if VERSION < v"0.7.0-DEV.2005" + using Base.Test +else + using Test +end +if !(VERSION < v"0.7.0-DEV.3026") + using Printf +end +if !(VERSION < v"0.7.0-DEV.1592") + using Base.MathConstants +end @test unsafe_load(DecFP.flags) == 0