From 34dcf31adc4c7850476421cb237b41c5b0e4e99e Mon Sep 17 00:00:00 2001 From: Fengyang Wang Date: Fri, 20 Jan 2017 22:07:46 -0500 Subject: [PATCH] Fix tests on 0.6 (#185) * Array constructor changes * Repair type lowering test --- src/JSON.jl | 6 +++--- src/bytes.jl | 2 +- src/specialized.jl | 2 +- test/lowering.jl | 2 +- test/runtests.jl | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/JSON.jl b/src/JSON.jl index 263d7bd..fd6deb7 100644 --- a/src/JSON.jl +++ b/src/JSON.jl @@ -17,7 +17,7 @@ import .Parser.parse "Internal JSON.jl implementation detail; do not depend on this type." immutable AssociativeWrapper{T} <: Associative{Symbol, Any} wrapped::T - fns::Array{Symbol, 1} + fns::Vector{Symbol} end AssociativeWrapper(x) = AssociativeWrapper(x, fieldnames(x)) @@ -58,7 +58,7 @@ if VERSION < v"0.5.0-dev+2396" end lower(c::Char) = string(c) -lower(d::DataType) = string(d) +lower(d::Type) = string(d) lower(m::Module) = throw(ArgumentError("cannot serialize Module $m as JSON")) lower(x::Real) = Float64(x) @@ -69,7 +69,7 @@ type State{I} indentstep::Int indentlen::Int prefix::AbstractString - otype::Array{Bool, 1} + otype::Vector{Bool} State(indentstep::Int) = new(indentstep, 0, "", diff --git a/src/bytes.jl b/src/bytes.jl index d33226e..94bf527 100644 --- a/src/bytes.jl +++ b/src/bytes.jl @@ -44,7 +44,7 @@ const ESCAPES = Dict( LATIN_T => TAB) const REVERSE_ESCAPES = Dict(map(reverse, ESCAPES)) -const ESCAPED_ARRAY = Array(Vector{UInt8}, 256) +const ESCAPED_ARRAY = Vector{Vector{UInt8}}(256) for c in 0x00:0xFF ESCAPED_ARRAY[c + 1] = if c == SOLIDUS [SOLIDUS] # don't escape this one diff --git a/src/specialized.jl b/src/specialized.jl index 42c7699..6ee9967 100644 --- a/src/specialized.jl +++ b/src/specialized.jl @@ -6,7 +6,7 @@ function parse_string(ps::MemoryParserState) fastpath, len = predict_string(ps) # Now read the string itself - b = Array{UInt8, 1}(len) + b = Vector{UInt8}(len) # Fast path occurs when the string has no escaped characters. This is quite # often the case in real-world data, especially when keys are short strings. diff --git a/test/lowering.jl b/test/lowering.jl index 8d4af5f..99e5dcb 100644 --- a/test/lowering.jl +++ b/test/lowering.jl @@ -9,7 +9,7 @@ immutable Type151{T} x::T end -@test JSON.json(Type151) == "\"Type151{T}\"" +@test JSON.parse(JSON.json(Type151)) == string(Type151) JSON.lower{T}(v::Type151{T}) = Dict(:type => T, :value => v.x) @test JSON.parse(JSON.json(Type151(1.0))) == Dict( diff --git a/test/runtests.jl b/test/runtests.jl index c03afd9..e56ae36 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,7 +30,7 @@ validate_e(e) = begin @test typeof(j["menu"]) == Dict{Compat.UTF8String, Any} @test length(j["menu"]) == 2 @test j["menu"]["header"] == "SVG\tViewerα" - @test isa(j["menu"]["items"], Array) + @test isa(j["menu"]["items"], Vector{Any}) @test length(j["menu"]["items"]) == 22 @test j["menu"]["items"][3] == nothing @test j["menu"]["items"][2]["id"] == "OpenNew" @@ -184,7 +184,7 @@ obj = JSON.parse("{\"a\":2e10}") #test for issue 21 a=JSON.parse(test21) -@test isa(a, Array{Any}) +@test isa(a, Vector{Any}) @test length(a) == 2 #Multidimensional arrays @test json([0 1; 2 0]) == "[[0,2],[1,0]]"