summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-30 18:12:05 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-30 18:12:05 +0000
commit428a637f0f7feffd33fed9a984844c6b0d167758 (patch)
tree9f5d407f0557cd3784054afc533ad2f56e9a37e6 /test/ruby
parent09cf4529269953847723eac4475bfe07c60b028a (diff)
merge revision(s) r46360,r46372: [Backport #8625]
* io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [ruby-core:55951] [Bug #8625] * io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [ruby-core:55951] [Bug #8625] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb8
-rw-r--r--test/ruby/test_pipe.rb13
2 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 115a498474..a7c5b2a39a 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1224,6 +1224,14 @@ class TestIO < Test::Unit::TestCase
t.value
assert_equal("", s)
end
+ with_pipe do |r, w|
+ s = "xxx"
+ t = Thread.new {r.read(2, s)}
+ Thread.pass until t.stop?
+ t.kill
+ t.value
+ assert_equal("xxx", s)
+ end
end
def test_write_nonblock
diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb
index 34f231ad8c..bcea91bebb 100644
--- a/test/ruby/test_pipe.rb
+++ b/test/ruby/test_pipe.rb
@@ -13,4 +13,17 @@ class TestPipe < Test::Unit::TestCase
r.close
end
end
+ class WithConversion < self
+ def open_file(content)
+ r, w = IO.pipe
+ w << content
+ w.close
+ r.set_encoding("us-ascii:utf-8")
+ begin
+ yield r
+ ensure
+ r.close
+ end
+ end
+ end
end