Skip to content

Commit dbcedf6

Browse files
femtocleaner[bot]stevengj
authored andcommitted
Fix deprecations (#88)
* Fix deprecations * tweaks * rm more compatibility code * Compat is no longer needed * clean up tests after femtocleaner
1 parent 69e3eec commit dbcedf6

File tree

3 files changed

+9
-80
lines changed

3 files changed

+9
-80
lines changed

REQUIRE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
julia 0.7
2-
Compat 0.61.0
32
BinaryProvider
43
SpecialFunctions

src/DecFP.jl

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
1-
VERSION < v"0.7.0-beta2.199" && __precompile__()
21

32
module DecFP
43

5-
using Compat, Compat.Printf, Compat.Unicode
6-
7-
# When Compat PR #491 is merged, REQUIRE that version and delete this
8-
# 0.7.0-DEV.3469
9-
@static if !isdefined(Base, :GC)
10-
@eval module GC
11-
using Base: gc
12-
const enable = Base.gc_enable
13-
@static if !isdefined(Base, Symbol("@gc_preserve"))
14-
macro preserve(args...)
15-
esc(args[end])
16-
end
17-
else
18-
@eval const $(Symbol("@preserve")) = Base.$(Symbol("@gc_preserve"))
19-
end
20-
end
21-
export GC
22-
end
23-
24-
@static if VERSION >= v"0.7.0-alpha.69"
25-
import SpecialFunctions
26-
end
4+
import SpecialFunctions
275

286
export Dec32, Dec64, Dec128, @d_str, @d32_str, @d64_str, @d128_str, exponent10, ldexp10
297

@@ -144,29 +122,6 @@ for w in (32,64,128)
144122
end
145123

146124
# quickly check whether s begins with "±nan"
147-
@static if VERSION < v"0.7.0-DEV.5126"
148-
149-
function isnanstr(s::AbstractString)
150-
i = start(s)
151-
while !done(s, i)
152-
c, i = next(s, i)
153-
isspace(c) || break
154-
end
155-
done(s, i) && return false
156-
if (c == '+' || c == '-')
157-
c, i = next(s, i)
158-
done(s, i) && return false
159-
end
160-
(c == 'n' || c == 'N') || return false
161-
c, i = next(s, i)
162-
(!done(s, i) && (c == 'a' || c == 'A')) || return false
163-
c, i = next(s, i)
164-
(done(s, i) && (c == 'n' || c == 'N')) || return false
165-
return true
166-
end
167-
168-
else
169-
170125
function isnanstr(s::AbstractString)
171126
st = iterate(s)
172127
c, i = '\0', 0
@@ -201,7 +156,6 @@ function isnanstr(s::AbstractString)
201156
return false
202157
end
203158

204-
end
205159

206160
"""
207161
exponent10(x::DecFP.DecimalFloatingPoint)
@@ -278,8 +232,8 @@ for w in (32,64,128)
278232
print(io, '-')
279233
end
280234
normalized_exponent = exponent10(x)
281-
lastdigitindex = Compat.findfirst(isequal(UInt8('E')), _buffer) - 1
282-
lastnonzeroindex = Compat.findlast(!isequal(UInt8('0')), view(_buffer, 1:lastdigitindex))
235+
lastdigitindex = findfirst(isequal(UInt8('E')), _buffer) - 1
236+
lastnonzeroindex = findlast(!isequal(UInt8('0')), view(_buffer, 1:lastdigitindex))
283237
if -5 < normalized_exponent < 6
284238
# %f
285239
if normalized_exponent >= 0
@@ -420,7 +374,7 @@ for w in (32,64,128)
420374
@eval Base.$f(x::$BID) = ccall(($(bidsym(w,c)), libbid), Cint, ($BID,), x) != 0
421375
end
422376

423-
for (f,c) in ((:+,"add"), (:-,"sub"), (:*,"mul"), (:/, "div"), (:hypot,"hypot"), (VERSION >= v"0.7.0-alpha.44" ? :atan : :atan2,"atan2"), (:^,"pow"), (:copysign,"copySign"))
377+
for (f,c) in ((:+,"add"), (:-,"sub"), (:*,"mul"), (:/, "div"), (:hypot,"hypot"), (:atan,"atan2"), (:^,"pow"), (:copysign,"copySign"))
424378
@eval Base.$f(x::$BID, y::$BID) = nox(ccall(($(bidsym(w,c)), libbid), $BID, ($BID,$BID), x, y))
425379
end
426380

@@ -432,13 +386,8 @@ for w in (32,64,128)
432386
@eval Base.$f(x::$BID) = @xchk(ccall(($(bidsym(w,c)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
433387
end
434388

435-
@static if VERSION >= v"0.7.0-alpha.69"
436-
@eval SpecialFunctions.lgamma(x::$BID) = @xchk(ccall(($(bidsym(w,:lgamma)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
437-
@eval SpecialFunctions.gamma(x::$BID) = @xchk(ccall(($(bidsym(w,:tgamma)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
438-
else
439-
@eval Base.lgamma(x::$BID) = @xchk(ccall(($(bidsym(w,:lgamma)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
440-
@eval Base.gamma(x::$BID) = @xchk(ccall(($(bidsym(w,:tgamma)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
441-
end
389+
@eval SpecialFunctions.lgamma(x::$BID) = @xchk(ccall(($(bidsym(w,:lgamma)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
390+
@eval SpecialFunctions.gamma(x::$BID) = @xchk(ccall(($(bidsym(w,:tgamma)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
442391

443392
for (r,c) in ((RoundingMode{:Nearest},"round_integral_nearest_even"), (RoundingMode{:NearestTiesAway},"round_integral_nearest_away"), (RoundingMode{:ToZero},"round_integral_zero"), (RoundingMode{:Up},"round_integral_positive"), (RoundingMode{:Down},"round_integral_negative"))
444393
@eval Base.round(x::$BID, ::$r) = @xchk(ccall(($(bidsym(w,c)), libbid), $BID, ($BID,), x), DomainError, x, mask=INVALID)
@@ -460,7 +409,7 @@ for w in (32,64,128)
460409
for c in (, :e, :ℯ, , :catalan, )
461410
@eval begin
462411
Base.convert(::Type{$BID}, ::Irrational{$(QuoteNode(c))}) = $(_parse(T, setprecision(256) do
463-
string(BigFloat(getfield(Compat.MathConstants, c)))
412+
string(BigFloat(getfield(MathConstants, c)))
464413
end))
465414
end
466415
end
@@ -554,13 +503,8 @@ for T in (Dec32, Dec64, Dec128)
554503
Base.eps(::Type{$T}) = $(_sub(_nextfloat(one(T)), one(T)))
555504
Base.typemax(::Type{$T}) = $(_parse(T, "+inf"))
556505
Base.typemin(::Type{$T}) = $(_parse(T, "-inf"))
557-
@static if isdefined(Base, :floatmax)
558506
Base.floatmax(::Type{$T}) = $(_prevfloat(_parse(T, "+inf")))
559507
Base.floatmin(::Type{$T}) = $(_nextfloat(zero(T)))
560-
else
561-
Base.realmax(::Type{$T}) = $(_prevfloat(_parse(T, "+inf")))
562-
Base.realmin(::Type{$T}) = $(_nextfloat(zero(T)))
563-
end
564508
end
565509
end
566510

test/runtests.jl

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
using DecFP, Compat, Compat.Test, Compat.Printf
2-
3-
if !(VERSION < v"0.7.0-DEV.1592")
4-
using Base.MathConstants
5-
end
6-
7-
if VERSION >= v"0.7.0-alpha.69"
8-
using SpecialFunctions
9-
end
10-
11-
if !isdefined(Base, :floatmax)
12-
floatmax(x) = realmax(x)
13-
floatmin(x) = realmin(x)
14-
end
15-
1+
using DecFP, Test, Printf, Base.MathConstants, SpecialFunctions
162

173
@test unsafe_load(DecFP.flags[]) == 0
184

195
import DecFP.isnanstr
206
@test isnanstr("nan") && isnanstr(" +NAN") && isnanstr("-NaN") && !isnanstr("nano")
217

228
for T in (Dec32, Dec64, Dec128)
23-
Compat.@info "TESTING $T ..."
9+
@info "TESTING $T ..."
2410

2511
if T == Dec32
2612
@test d32"3.2" * d32"4.5" == d32"14.4"

0 commit comments

Comments
 (0)