diff --git a/.travis.yml b/.travis.yml index 1b8ea91..b805f4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ os: - osx - linux julia: - - 0.4 - 0.5 + - 0.6 - nightly notifications: email: false diff --git a/REQUIRE b/REQUIRE index 7274a2c..6463e31 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia 0.4 +julia 0.5 Compat 0.24.0 diff --git a/appveyor.yml b/appveyor.yml index bfd78e7..57d4bfa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,9 @@ environment: matrix: - - JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe" - - JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe" - JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe" - JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" + - JULIAVERSION: "julialang/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" + - JULIAVERSION: "julialang/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" - JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe" - JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe" diff --git a/src/Parser.jl b/src/Parser.jl index d6938e6..941aea1 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -123,7 +123,7 @@ end # Throws an error message with an indicator to the source function _error(message::AbstractString, ps::MemoryParserState) - orig = Compat.UTF8String(ps.utf8data) + orig = String(ps.utf8data) lines = _count_before(orig, '\n', ps.s) # Replace all special multi-line/multi-space characters with a space. strnl = replace(orig, r"[\b\f\n\r\t\s]", " ") @@ -279,7 +279,7 @@ function parse_string(ps::ParserState) elseif c < SPACE _error(E_BAD_CONTROL, ps) elseif c == STRING_DELIM - return Compat.UTF8String(b) + return String(b) end push!(b, c) @@ -366,12 +366,12 @@ end function unparameterize_type{T}(::Type{T}) - candidate = typeintersect(T, Associative{Compat.UTF8String, Any}) + candidate = typeintersect(T, Associative{String, Any}) candidate <: Union{} ? T : candidate end -function parse{T<:Associative}(str::AbstractString; dicttype::Type{T}=Dict{Compat.UTF8String,Any}) - ps = MemoryParserState(Vector{UInt8}(Compat.UTF8String(str)), 1) +function parse{T<:Associative}(str::AbstractString; dicttype::Type{T}=Dict{String,Any}) + ps = MemoryParserState(Vector{UInt8}(String(str)), 1) v = parse_value(ps, unparameterize_type(T)) chomp_space!(ps) if hasmore(ps) @@ -380,15 +380,15 @@ function parse{T<:Associative}(str::AbstractString; dicttype::Type{T}=Dict{Compa v end -function parse{T<:Associative}(io::IO; dicttype::Type{T}=Dict{Compat.UTF8String,Any}) +function parse{T<:Associative}(io::IO; dicttype::Type{T}=Dict{String,Any}) ps = StreamingParserState(io) parse_value(ps, unparameterize_type(T)) end -function parsefile{T<:Associative}(filename::AbstractString; dicttype::Type{T}=Dict{Compat.UTF8String, Any}, use_mmap=true) +function parsefile{T<:Associative}(filename::AbstractString; dicttype::Type{T}=Dict{String, Any}, use_mmap=true) sz = filesize(filename) open(filename) do io - s = use_mmap ? Compat.UTF8String(Mmap.mmap(io, Vector{UInt8}, sz)) : readstring(io) + s = use_mmap ? String(Mmap.mmap(io, Vector{UInt8}, sz)) : readstring(io) parse(s; dicttype=dicttype) end end diff --git a/src/Writer.jl b/src/Writer.jl index c686215..374d1db 100644 --- a/src/Writer.jl +++ b/src/Writer.jl @@ -43,13 +43,7 @@ function lower(a) end end -if isdefined(Base, :Dates) - lower(s::Base.Dates.TimeType) = string(s) -end - -if VERSION < v"0.5.0-dev+2396" - lower(f::Function) = "function at $(f.fptr)" -end +lower(s::Base.Dates.TimeType) = string(s) # To avoid allocating an intermediate string, we directly define `show_json` # for this type instead of lowering it to a string first (which would @@ -258,7 +252,7 @@ end function show_json(io::SC, s::CS, x::Union{Integer, AbstractFloat}) # workaround for issue in Julia 0.5.x where Float32 values are printed as # 3.4f-5 instead of 3.4e-5 - @static if v"0.5-" <= VERSION < v"0.6.0-dev.788" + @static if VERSION < v"0.6.0-dev.788" if isa(x, Float32) return show_json(io, s, Float64(x)) end @@ -313,7 +307,7 @@ function show_json{T,n}(io::SC, s::CS, A::AbstractArray{T,n}) begin_array(io) newdims = ntuple(_ -> :, Val{n - 1}) for j in 1:size(A, n) - show_element(io, s, Compat.view(A, newdims..., j)) + show_element(io, s, view(A, newdims..., j)) end end_array(io) end diff --git a/src/specialized.jl b/src/specialized.jl index 4f759d1..7738c37 100644 --- a/src/specialized.jl +++ b/src/specialized.jl @@ -20,7 +20,7 @@ function parse_string(ps::MemoryParserState) parse_string(ps, b) end - Compat.UTF8String(b) + String(b) end """ diff --git a/test/lowering.jl b/test/lowering.jl index 6aae3eb..deca632 100644 --- a/test/lowering.jl +++ b/test/lowering.jl @@ -4,7 +4,6 @@ using JSON using Base.Test using Compat using FixedPointNumbers: Fixed -import Compat: String if isdefined(Base, :Dates) @test JSON.json(Date(2016, 8, 3)) == "\"2016-08-03\"" diff --git a/test/runtests.jl b/test/runtests.jl index df46a7b..c1f28b0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,6 @@ using JSON using Base.Test using Compat -import Compat: String import DataStructures @@ -24,9 +23,9 @@ validate_c(c) = begin validate_e(e) = begin j=JSON.parse(e) @test j != nothing - @test typeof(j) == Dict{Compat.UTF8String, Any} + @test typeof(j) == Dict{String, Any} @test length(j) == 1 - @test typeof(j["menu"]) == Dict{Compat.UTF8String, Any} + @test typeof(j["menu"]) == Dict{String, Any} @test length(j["menu"]) == 2 @test j["menu"]["header"] == "SVG\tViewerα" @test isa(j["menu"]["items"], Vector{Any}) @@ -50,11 +49,7 @@ validate_unicode(unicode) = begin end # ------- -if VERSION >= v"0.5.0-dev+1343" - finished_async_tests = RemoteChannel() -else - finished_async_tests = RemoteRef() -end +finished_async_tests = RemoteChannel() @async begin s = listen(7777) @@ -174,7 +169,7 @@ json_zeros = json(zeros) # Printing an empty array or Dict shouldn't cause a BoundsError -@test json(Compat.ASCIIString[]) == "[]" +@test json(String[]) == "[]" @test json(Dict()) == "{}" #test for issue 26 @@ -274,10 +269,6 @@ end @test Float32(JSON.parse(json(2.1f-8))) == 2.1f-8 # Check printing of more exotic objects -if VERSION < v"0.5.0-dev+2396" - # Test broken in v0.5, code is using internal structure of Function type! - @test sprint(JSON.print, sprint) == string("\"function at ", sprint.fptr, "\"") -end @test sprint(JSON.print, Float64) == string("\"Float64\"") @test_throws ArgumentError sprint(JSON.print, JSON) diff --git a/test/serializer.jl b/test/serializer.jl index 98fd2e9..57f0dbe 100644 --- a/test/serializer.jl +++ b/test/serializer.jl @@ -3,7 +3,6 @@ module TestSerializer using JSON using Base.Test using Compat -import Compat: String # to define a new serialization behaviour, import these first import JSON.Serializations: CommonSerialization, StandardSerialization @@ -45,7 +44,7 @@ JSON.show_json(io::SC, ::NaNSerialization, f::AbstractFloat) = # issue #170: Print JavaScript functions directly immutable JSSerialization <: CS end immutable JSFunction - data::Compat.UTF8String + data::String end function JSON.show_json(io::SC, ::JSSerialization, f::JSFunction)