diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-20 06:13:17 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-20 06:13:17 +0000 |
commit | ae2921ae67e849f8d28c0a3ae170d38c6ac36d03 (patch) | |
tree | f4a44cdfe42f0be2e99e06ef50d202369a1f0171 /test | |
parent | 64a16b9ede4dfc72f8c4b486ebce148f519e60dc (diff) | |
download | ruby-ae2921ae67e849f8d28c0a3ae170d38c6ac36d03.tar.gz |
* io.c (copy_stream_rbuf_to_dst): removed.
(copy_stream_fallback_body): don't bypass write method.
(copy_stream_body): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index e0c3c3d964..44f1cfafc9 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -310,6 +310,20 @@ class TestIO < Test::Unit::TestCase } end + def test_copy_stream_rbuf + mkcdtmpdir {|d| + with_pipe {|r, w| + File.open("foo", "w") {|f| f << "abcd" } + File.open("foo") {|f| + f.read(1) + assert_equal(3, IO.copy_stream(f, w, 10, 1)) + } + w.close + assert_equal("bcd", r.read) + } + } + end + def with_socketpair s1, s2 = UNIXSocket.pair begin @@ -473,4 +487,25 @@ class TestIO < Test::Unit::TestCase } end + def test_copy_stream_strio_flush + with_pipe {|r, w| + w.sync = false + w.write "zz" + src = StringIO.new("abcd") + IO.copy_stream(src, w) + w.close + assert_equal("zzabcd", r.read) + } + end + + def test_copy_stream_strio_rbuf + with_pipe {|r, w| + w << "abcd" + w.close + assert_equal("a", r.read(1)) + sio = StringIO.new + IO.copy_stream(r, sio) + assert_equal("bcd", sio.string) + } + end end |