Skip to content

Commit 69e85aa

Browse files
authored
Merge pull request #15 from JuliaMath/cv/deprecations
Fix most Julia 0.7 deprecations
2 parents 769a89e + 5a30344 commit 69e85aa

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.5
2-
Compat 0.17.0
2+
Compat 0.33

src/FixedPointDecimals.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function convert{T, f, U, g}(::Type{FD{T, f}}, x::FD{U, g})
277277
if r == 0
278278
reinterpret(FD{T, f}, T(q))
279279
else
280-
throw(InexactError())
280+
throw(InexactError(:convert, FD{T, f}, x))
281281
end
282282
end
283283
end
@@ -299,7 +299,7 @@ function convert{TF <: BigFloat, T, f}(::Type{TF}, x::FD{T, f})::TF
299299
end
300300

301301
function convert{TI <: Integer, T, f}(::Type{TI}, x::FD{T, f})::TI
302-
isinteger(x) || throw(InexactError())
302+
isinteger(x) || throw(InexactError(:convert, TI, x))
303303
div(x.i, coefficient(FD{T, f}))
304304
end
305305

@@ -380,7 +380,7 @@ function parse{T, f}(::Type{FD{T, f}}, str::AbstractString, mode::RoundingMode=R
380380
end
381381

382382
# Parse exponent information
383-
exp_index = findfirst(str, 'e')
383+
exp_index = findfirst(equalto('e'), str)
384384
if exp_index > 0
385385
exp = parse(Int, str[(exp_index + 1):end])
386386
sig_end = exp_index - 1
@@ -391,7 +391,7 @@ function parse{T, f}(::Type{FD{T, f}}, str::AbstractString, mode::RoundingMode=R
391391

392392
# Remove the decimal place from the string
393393
sign = T(first(str) == '-' ? -1 : 1)
394-
dec_index = findfirst(str, '.')
394+
dec_index = findfirst(equalto('.'), str)
395395
sig_start = sign < 0 ? 2 : 1
396396
if dec_index > 0
397397
int_str = str[sig_start:(dec_index - 1)] * str[(dec_index + 1):sig_end]
@@ -412,7 +412,7 @@ function parse{T, f}(::Type{FD{T, f}}, str::AbstractString, mode::RoundingMode=R
412412
val = isempty(a) ? T(0) : sign * parse(T, a)
413413
if !isempty(b) && any(collect(b[2:end]) .!= '0')
414414
if mode == RoundThrows
415-
throw(InexactError())
415+
throw(InexactError(:parse, FD{T, f}, str))
416416
elseif mode == RoundNearest
417417
val += sign * parse_round(T, b, mode)
418418
end

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using FixedPointDecimals
22
import FixedPointDecimals: FD, value
3-
using Base.Test
43
using Compat
4+
using Compat.Test
55
import Base.Checked: checked_mul
66

77
include("utils.jl")
88

9-
@testset "FixedPointDecimals" begin
10-
119
const SFD2 = FixedDecimal{Int16, 2}
1210
const SFD4 = FixedDecimal{Int16, 4}
1311
const FD1 = FixedDecimal{Int, 1}
@@ -72,6 +70,8 @@ function parse_int{T, f}(::Type{FD{T, f}}, val::AbstractString; ceil::Bool=false
7270
reinterpret(FD{T, f}, parse(T, val[1:(f + 1)]) + T(ceil))
7371
end
7472

73+
@testset "FixedPointDecimals" begin
74+
7575
# Basic tests for the methods created above
7676
@testset "alt" begin
7777
@test trunc_alt(FD2, 0.0) == FD2(0)

test/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function integer_alt{T<:Integer}(::Type{T}, dp::Integer, val::AbstractFloat)
1919
# perform any rounding.
2020
str = float_string(val)
2121
sign = T(first(str) == '-' ? -1 : 1)
22-
decimal = findfirst(str, '.')
22+
decimal = findfirst(equalto('.'), str)
2323
int_start = sign < 0 ? 2 : 1
2424
int_end = decimal + dp
2525
v = parse(T, str[int_start:(decimal - 1)] * str[(decimal + 1):int_end])

0 commit comments

Comments
 (0)