From 0c6b85a86819172b85e520bcc5444be5ab4004c5 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Fri, 20 Jan 2017 05:28:31 -0800 Subject: [PATCH] Fix deprecations and test on nightly deprecation warning test was failing due to bold control characters --- REQUIRE | 2 +- src/ZMQ.jl | 12 ++++++------ test/runtests.jl | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/REQUIRE b/REQUIRE index 1558574..a08e057 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.4 BinDeps 0.3.21 @osx Homebrew -Compat 0.8.0 +Compat 0.9.5 @windows WinRPM diff --git a/src/ZMQ.jl b/src/ZMQ.jl index 4b021e4..cbe1c62 100644 --- a/src/ZMQ.jl +++ b/src/ZMQ.jl @@ -139,7 +139,7 @@ type Context if p == C_NULL throw(StateError(jl_zmq_error_str())) end - zctx = new(p, Array(Socket,0)) + zctx = new(p, Socket[]) finalizer(zctx, close) return zctx end @@ -418,7 +418,7 @@ end isfreed(m::Message) = haskey(gc_protect, m.handle) # AbstractArray behaviors: -similar(a::Message, T, dims::Dims) = Array(T, dims) # ? +similar(a::Message, T, dims::Dims) = Array{T}(dims) # ? length(zmsg::Message) = @compat Int(ccall((:zmq_msg_size, zmq), Csize_t, (Ptr{Message},), &zmsg)) size(zmsg::Message) = (length(zmsg),) unsafe_convert(::Type{Ptr{UInt8}}, zmsg::Message) = ccall((:zmq_msg_data, zmq), Ptr{UInt8}, (Ptr{Message},), &zmsg) @@ -571,11 +571,11 @@ const FORWARDER = 2 const QUEUE = 3 function __init__() - major = Array(Cint,1) - minor = Array(Cint,1) - patch = Array(Cint,1) + major = Ref{Cint}() + minor = Ref{Cint}() + patch = Ref{Cint}() ccall((:zmq_version, zmq), Void, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), major, minor, patch) - global const version = VersionNumber(major[1], minor[1], patch[1]) + global const version = VersionNumber(major[], minor[], patch[]) if version < v"3" error("ZMQ version $version < 3 is not supported") end diff --git a/test/runtests.jl b/test/runtests.jl index 07dae84..8059569 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,7 +76,7 @@ ZMQ.send(s2, Message("another test request")) msg = ZMQ.recv(s1) o=convert(IOStream, msg) seek(o, 0) -@assert (takebuf_string(o)=="another test request") +@assert (String(take!(o))=="another test request") ZMQ.close(s1) ZMQ.close(s2) @@ -84,6 +84,8 @@ ZMQ.close(ctx2) # deprecate bytestring(::Message) let olderr = STDERR + old_have_color = Base.have_color + eval(Base, :(have_color = false)) # avoid control characters in output rderr, wrerr = redirect_stderr() reader = @async readstring(rderr) @assert bytestring(Message("hello")) == "hello" @@ -94,4 +96,5 @@ let olderr = STDERR else @assert contains(wait(reader), "WARNING: bytestring(zmsg::Message) is deprecated") end + eval(Base, :(have_color = $old_have_color)) # avoid control characters in output end