From ae2921ae67e849f8d28c0a3ae170d38c6ac36d03 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 20 Apr 2008 06:13:17 +0000 Subject: * 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 --- test/ruby/test_io.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test') 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 -- cgit v1.2.3