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 | 7682b70a5cf39fbd136aa12daba00772ad42c50e (patch) | |
| tree | f4a44cdfe42f0be2e99e06ef50d202369a1f0171 /test/ruby | |
| parent | 4a31927d235af622f5f13e0364b70a1c49fe269c (diff) | |
| download | ruby-7682b70a5cf39fbd136aa12daba00772ad42c50e.tar.gz ruby-7682b70a5cf39fbd136aa12daba00772ad42c50e.tar.xz ruby-7682b70a5cf39fbd136aa12daba00772ad42c50e.zip | |
* io.c (copy_stream_rbuf_to_dst): removed.
(copy_stream_fallback_body): don't bypass write method.
(copy_stream_body): simplified.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -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 e0c3c3d96..44f1cfafc 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 |
