Skip to content

Commit

Permalink
restore fix and test with workaround for JuliaInterop#166
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeits committed Feb 22, 2018
1 parent 18cb14d commit ed5bf80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ end
isfreed(m::Message) = haskey(gc_protect, m.handle)

# AbstractArray behaviors:
similar(a::Message, T, dims::Dims) = Array{T}(dims) # ?
similar(a::Message, ::Type{T}, dims::Dims) where {T} = Array{T}(dims) # ?
# TODO: change `Any` to `Ref{Message}` when 0.6 support is dropped.
length(zmsg::Message) = Int(ccall((:zmq_msg_size, zmq), Csize_t, (Any,), zmsg))
size(zmsg::Message) = (length(zmsg),)
Expand Down
12 changes: 7 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ s2=Socket(ctx2, REQ)
ZMQ.bind(s1, "tcp://*:5555")
ZMQ.connect(s2, "tcp://localhost:5555")

ZMQ.send(s2, Message("test request"))
msg = Message("test request")
# Test similar() and copy() fixes in https://github.com/JuliaInterop/ZMQ.jl/pull/165
# Note that we have to send this message to work around
# https://github.com/JuliaInterop/ZMQ.jl/issues/166
@assert similar(msg, UInt8, 12) isa Vector{UInt8}
@assert copy(msg) == convert(Vector{UInt8}, "test request")
ZMQ.send(s2, msg)
@assert (unsafe_string(ZMQ.recv(s1)) == "test request")
ZMQ.send(s1, Message("test response"))
@assert (unsafe_string(ZMQ.recv(s2)) == "test response")

msg = Message("hello")
# @assert similar(msg, UInt8, 5) isa Vector{UInt8}
# @assert copy(msg) == UInt8[0x68, 0x65, 0x6c, 0x6c, 0x6f]

# Test task-blocking behavior
c = Base.Condition()
msg_sent = false
Expand Down

0 comments on commit ed5bf80

Please sign in to comment.