Skip to content

Commit

Permalink
Fix all existing deprecation warnings (#240)
Browse files Browse the repository at this point in the history
* Fix Distributed module deprecation

* Fix IOBuffer deprecation

* Fix lpad deprecation

* Fix convert fallback deprecation

* Fix Symbol convert deprecation
  • Loading branch information
iamed2 authored and TotalVerb committed Feb 20, 2018
1 parent 0081227 commit a4ad8ba
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function parse_object(pc::ParserContext{DictType, <:Real}, ps::ParserState) wher
# Read value
value = parse_value(pc, ps)
chomp_space!(ps)
obj[convert(keyT, key)] = value
obj[keyT === Symbol ? Symbol(key) : convert(keyT, key)] = value
byteat(ps) == OBJECT_END && break
skip!(ps, DELIMITER)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const IsPrintedAsString = Union{
lower(x::IsPrintedAsString) = x

lower(m::Module) = throw(ArgumentError("cannot serialize Module $m as JSON"))
lower(x::Real) = Float64(x)
lower(x::Real) = convert(Float64, x)
lower(x::Base.AbstractSet) = collect(x)

"""
Expand Down
2 changes: 1 addition & 1 deletion src/specialized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function parse_string(ps::MemoryParserState)
ps.s = s + len + 2 # byte after closing quote
return unsafe_string(pointer(ps.utf8)+s, len)
else
String(take!(parse_string(ps, IOBuffer(len))))
String(take!(parse_string(ps, IOBuffer(maxsize=len))))
end
end

Expand Down
6 changes: 3 additions & 3 deletions test/json-checker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
const JSON_DATA_DIR = joinpath(dirname(@__DIR__), "data")

for i in 1:38
file = "fail$(lpad(i, 2, 0)).json"
file = "fail$(lpad(string(i), 2, "0")).json"
filepath = joinpath(JSON_DATA_DIR, "jsonchecker", file)

@test_throws ErrorException JSON.parsefile(filepath)
end

for i in 1:3
# Test that the files parse successfully and match streaming parser
tf = joinpath(JSON_DATA_DIR, "jsonchecker", "pass$(lpad(i, 2, 0)).json")
tf = joinpath(JSON_DATA_DIR, "jsonchecker", "pass$(lpad(string(i), 2, "0")).json")
@test JSON.parsefile(tf) == open(JSON.parse, tf)
end

Expand All @@ -20,7 +20,7 @@ end
roundtrip(data) = JSON.json(JSON.Parser.parse(data))

for i in 1:27
file = "roundtrip$(lpad(i, 2, 0)).json"
file = "roundtrip$(lpad(string(i), 2, "0")).json"
filepath = joinpath(JSON_DATA_DIR, "roundtrip", file)

rt = roundtrip(read(filepath, String))
Expand Down
2 changes: 1 addition & 1 deletion test/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ JSON.lower(v::Type151{T}) where {T} = Dict(:type => T, :value => v.x)
"value" => 1.0)

fixednum = Fixed{Int16, 15}(0.1234)
@test JSON.parse(JSON.json(fixednum)) == Float64(fixednum)
@test JSON.parse(JSON.json(fixednum)) == convert(Float64, fixednum)

# test that the default string-serialization of enums can be overriden by
# `lower` if needed
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using JSON
using Compat.Test
using Compat
using Compat.Dates
using Compat.Distributed: RemoteChannel
using OffsetArrays

import DataStructures
Expand Down Expand Up @@ -73,7 +74,7 @@ end

@testset "Regression" begin
@testset "for issue #$i" for i in [21, 26, 57, 109, 152, 163]
include("regression/issue$(lpad(i, 3, '0')).jl")
include("regression/issue$(lpad(string(i), 3, "0")).jl")
end
end

Expand Down

0 comments on commit a4ad8ba

Please sign in to comment.