diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 81b8e4aeab..83d7fda24b 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -972,7 +972,7 @@ class TestIO < Test::Unit::TestCase with_pipe do |r, w| s = "" t = Thread.new { r.readpartial(5, s) } - Thread.pass until s.size == 5 + Thread.pass until t.stop? assert_raise(RuntimeError) { s.clear } w.write "foobarbaz" w.close @@ -991,6 +991,17 @@ class TestIO < Test::Unit::TestCase } end + def test_readpartial_buffer_error + with_pipe do |r, w| + s = "" + t = Thread.new { r.readpartial(5, s) } + Thread.pass until t.stop? + t.kill + t.value + assert_equal("", s) + end + end + def test_read pipe(proc do |w| w.write "foobarbaz" @@ -1007,7 +1018,7 @@ class TestIO < Test::Unit::TestCase with_pipe do |r, w| s = "" t = Thread.new { r.read(5, s) } - Thread.pass until s.size == 5 + Thread.pass until t.stop? assert_raise(RuntimeError) { s.clear } w.write "foobarbaz" w.close @@ -1015,6 +1026,17 @@ class TestIO < Test::Unit::TestCase end end + def test_read_buffer_error + with_pipe do |r, w| + s = "" + t = Thread.new { r.read(5, s) } + Thread.pass until t.stop? + t.kill + t.value + assert_equal("", s) + end + end + def test_write_nonblock skip "IO#write_nonblock is not supported on file/pipe." if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM pipe(proc do |w| @@ -2117,8 +2139,8 @@ End end } IO.pipe {|r,w| - assert(r.close_on_exec?) - assert(w.close_on_exec?) + assert(r.close_on_exec?) + assert(w.close_on_exec?) } end |