Skip to content

Commit

Permalink
fix method ambiguity in similar() (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeits authored and stevengj committed Apr 3, 2018
1 parent e445ff2 commit 6ed45b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,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
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ 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")
Expand Down

0 comments on commit 6ed45b5

Please sign in to comment.