Skip to content

Commit 88e9b2c

Browse files
committed
Fix specs for Socket.pack_sockaddr_in
1 parent 800789f commit 88e9b2c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/truffle/socket/truffle/foreign.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,15 @@ def self.pack_sockaddr_in(host, port, family = ::Socket::AF_UNSPEC,
266266
# to succeed on some platforms (most notably, Solaris).
267267
Integer(port)
268268
type = ::Socket::SOCK_DGRAM
269-
rescue ArgumentError
269+
rescue ArgumentError, TypeError
270270
# Ignored.
271271
end
272272
end
273273

274+
if Primitive.nil?(port)
275+
port = 0
276+
end
277+
274278
hints = Addrinfo.new
275279

276280
hints[:ai_family] = family

spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
require_relative '../fixtures/classes'
33
require_relative '../shared/pack_sockaddr'
44

5-
describe "Socket#pack_sockaddr_in" do
5+
describe "Socket.pack_sockaddr_in" do
66
it_behaves_like :socket_pack_sockaddr_in, :pack_sockaddr_in
77
end

spec/tags/library/socket/socket/pack_sockaddr_in_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)