summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-13 09:30:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-13 09:30:40 +0000
commitdf77202b372535d58fccc244113fd9944c7b01c0 (patch)
treed74b17fe865023828138a7d841428ce90864fedb /test
parent23ebb5ea6cdff94d840b34ab7ef78e73ee442e75 (diff)
* io.c (io_setstrbuf): defer resizing buffer string until data is
read actually. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb30
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