From 1a00db7fa747d81843d392616877dfa696b5ef9a Mon Sep 17 00:00:00 2001 From: Fengyang Wang Date: Sun, 23 Apr 2017 21:31:58 -0400 Subject: [PATCH 1/2] Drop v0.4 support --- .travis.yml | 2 +- REQUIRE | 2 +- appveyor.yml | 4 ++-- src/Parser.jl | 16 ++++++++-------- src/Writer.jl | 2 +- src/specialized.jl | 2 +- test/lowering.jl | 1 - test/runtests.jl | 7 +++---- test/serializer.jl | 3 +-- 9 files changed, 18 insertions(+), 21 deletions(-) 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 63f7333..7553293 100644 --- a/src/Writer.jl +++ b/src/Writer.jl @@ -301,7 +301,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 ae3daf3..8e30109 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 7bba04b..bd971f8 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}) @@ -174,7 +173,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 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) From 53492b2a02f398d2f6e9f9d6152efb4ca5b8d8e6 Mon Sep 17 00:00:00 2001 From: Fengyang Wang Date: Thu, 27 Apr 2017 18:22:04 -0400 Subject: [PATCH 2/2] More removal of 0.4-related code --- src/Writer.jl | 10 ++-------- test/runtests.jl | 10 +--------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Writer.jl b/src/Writer.jl index 7553293..505f059 100644 --- a/src/Writer.jl +++ b/src/Writer.jl @@ -46,13 +46,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) lower(c::Char) = string(c) lower(d::Type) = string(d) @@ -246,7 +240,7 @@ show_json(io::SC, ::CS, x::Union{AbstractString, Symbol}) = show_string(io, x) 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 diff --git a/test/runtests.jl b/test/runtests.jl index bd971f8..19bd84e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -49,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) @@ -267,10 +263,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)