From 988ca60565a5ba6661f7215026f008afebcf7aee Mon Sep 17 00:00:00 2001 From: tenderlove Date: Mon, 26 Aug 2013 22:41:44 +0000 Subject: * io.c (io_read_nonblock): support non-blocking reads without raising exceptions. As in: `io.read_nonblock(size, exception: false)` [ruby-core:38666] [Feature #5138] * ext/openssl/ossl_ssl.c (ossl_ssl_read_internal): ditto * ext/stringio/stringio.c (strio_sysread): ditto * io.c (rb_io_write_nonblock): support non-blocking writes without raising an exception. * ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): ditto * test/openssl/test_pair.rb (class OpenSSL): tests * test/ruby/test_io.rb (class TestIO): ditto * test/socket/test_nonblock.rb (class TestSocketNonblock): ditto * test/stringio/test_stringio.rb (class TestStringIO): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/socket/test_nonblock.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/socket') diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb index d494f91c41..e395a0ad31 100644 --- a/test/socket/test_nonblock.rb +++ b/test/socket/test_nonblock.rb @@ -190,6 +190,20 @@ class TestSocketNonblock < Test::Unit::TestCase s.close if s end + def test_read_nonblock_no_exception + c, s = tcp_pair + assert_equal :wait_readable, c.read_nonblock(100, exception: false) + assert_equal :wait_readable, s.read_nonblock(100, exception: false) + c.write("abc") + IO.select [s] + assert_equal("a", s.read_nonblock(1, exception: false)) + assert_equal("bc", s.read_nonblock(100, exception: false)) + assert_equal :wait_readable, s.read_nonblock(100, exception: false) + ensure + c.close if c + s.close if s + end + =begin def test_write_nonblock c, s = tcp_pair -- cgit v1.2.3