diff options
Diffstat (limited to 'spec/ruby/library/socket/basicsocket')
-rw-r--r-- | spec/ruby/library/socket/basicsocket/recv_spec.rb | 19 | ||||
-rw-r--r-- | spec/ruby/library/socket/basicsocket/send_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/library/socket/basicsocket/shutdown_spec.rb | 20 |
3 files changed, 31 insertions, 12 deletions
diff --git a/spec/ruby/library/socket/basicsocket/recv_spec.rb b/spec/ruby/library/socket/basicsocket/recv_spec.rb index b6ccda5d00..a56114f4ab 100644 --- a/spec/ruby/library/socket/basicsocket/recv_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recv_spec.rb @@ -32,6 +32,25 @@ describe "BasicSocket#recv" do ScratchPad.recorded.should == 'hello' end + ruby_version_is "3.3" do + it "returns nil on a closed stream socket" do + t = Thread.new do + client = @server.accept + packet = client.recv(10) + client.close + packet + end + + Thread.pass while t.status and t.status != "sleep" + t.status.should_not be_nil + + socket = TCPSocket.new('127.0.0.1', @port) + socket.close + + t.value.should be_nil + end + end + platform_is_not :solaris do it "accepts flags to specify unusual receiving behaviour" do t = Thread.new do diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb index 868801df30..041ce03d72 100644 --- a/spec/ruby/library/socket/basicsocket/send_spec.rb +++ b/spec/ruby/library/socket/basicsocket/send_spec.rb @@ -22,7 +22,7 @@ describe "BasicSocket#send" do client = @server.accept loop do got = client.recv(5) - break if got.empty? + break if got.nil? || got.empty? data << got end client.close @@ -67,7 +67,7 @@ describe "BasicSocket#send" do client = @server.accept loop do got = client.recv(5) - break if got.empty? + break if got.nil? || got.empty? data << got end client.close diff --git a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb index 41d9581bde..c78b32de38 100644 --- a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb +++ b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb @@ -23,7 +23,7 @@ platform_is_not :windows do # hangs it 'shuts down a socket for reading' do @client.shutdown(Socket::SHUT_RD) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for writing' do @@ -35,7 +35,7 @@ platform_is_not :windows do # hangs it 'shuts down a socket for reading and writing' do @client.shutdown(Socket::SHUT_RDWR) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty -> { @client.write('hello') }.should raise_error(Errno::EPIPE) end @@ -49,13 +49,13 @@ platform_is_not :windows do # hangs it 'shuts down a socket for reading using :RD' do @client.shutdown(:RD) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for reading using :SHUT_RD' do @client.shutdown(:SHUT_RD) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for writing using :WR' do @@ -73,7 +73,7 @@ platform_is_not :windows do # hangs it 'shuts down a socket for reading and writing' do @client.shutdown(:RDWR) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty -> { @client.write('hello') }.should raise_error(Errno::EPIPE) end @@ -87,13 +87,13 @@ platform_is_not :windows do # hangs it 'shuts down a socket for reading using "RD"' do @client.shutdown('RD') - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for reading using "SHUT_RD"' do @client.shutdown('SHUT_RD') - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for writing using "WR"' do @@ -123,7 +123,7 @@ platform_is_not :windows do # hangs @client.shutdown(@dummy) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for reading using "SHUT_RD"' do @@ -131,7 +131,7 @@ platform_is_not :windows do # hangs @client.shutdown(@dummy) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty end it 'shuts down a socket for reading and writing' do @@ -139,7 +139,7 @@ platform_is_not :windows do # hangs @client.shutdown(@dummy) - @client.recv(1).should be_empty + @client.recv(1).to_s.should be_empty -> { @client.write('hello') }.should raise_error(Errno::EPIPE) end |