diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 0f4d5234a0..d984252cb5 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -991,6 +991,16 @@ class TestIO < Test::Unit::TestCase } end + def test_readpartial_with_not_empty_buffer + pipe(proc do |w| + w.write "foob" + w.close + end, proc do |r| + r.readpartial(5, s = "01234567") + assert_equal("foob", s) + end) + end + def test_readpartial_buffer_error with_pipe do |r, w| s = "" @@ -1026,6 +1036,16 @@ class TestIO < Test::Unit::TestCase end end + def test_read_with_not_empty_buffer + pipe(proc do |w| + w.write "foob" + w.close + end, proc do |r| + r.read(nil, s = "01234567") + assert_equal("foob", s) + end) + end + def test_read_buffer_error with_pipe do |r, w| s = "" @@ -1047,6 +1067,17 @@ class TestIO < Test::Unit::TestCase end) end + def test_read_nonblock_with_not_empty_buffer + skip "IO#read_nonblock is not supported on file/pipe." if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM + pipe(proc do |w| + w.write "foob" + w.close + end, proc do |r| + r.read_nonblock(5, s = "01234567") + assert_equal("foob", s) + end) + end + def test_read_nonblock_error return if !have_nonblock? skip "IO#read_nonblock is not supported on file/pipe." if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM @@ -1417,6 +1448,16 @@ class TestIO < Test::Unit::TestCase end end + def test_sysread_with_not_empty_buffer + pipe(proc do |w| + w.write "foob" + w.close + end, proc do |r| + r.sysread( 5, s = "01234567" ) + assert_equal( "foob", s ) + end) + end + def test_flag t = make_tempfile |