summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-21 10:09:33 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-21 10:09:33 +0000
commit408728d75dd12fc21d6246a9473fd08a26d75a22 (patch)
treed3e81fe5a5226b838aa9c8cdc6205b7f488464e2 /test
parent7e9d9833684c0ca428970b14e050664fe7380078 (diff)
downloadruby-408728d75dd12fc21d6246a9473fd08a26d75a22.tar.gz
ruby-408728d75dd12fc21d6246a9473fd08a26d75a22.tar.xz
ruby-408728d75dd12fc21d6246a9473fd08a26d75a22.zip
* io.c (copy_stream_body): call rb_io_check_readable and
rb_io_check_writable. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 5ed0ac4d5..06da5db74 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -237,7 +237,6 @@ class TestIO < Test::Unit::TestCase
}
}
-
bigcontent = "abc" * 123456
File.open("bigsrc", "w") {|f| f << bigcontent }
ret = IO.copy_stream("bigsrc", "bigdst")
@@ -511,4 +510,39 @@ class TestIO < Test::Unit::TestCase
assert_equal("bcd", sio.string)
}
end
+
+ def test_copy_stream_src_wbuf
+ mkcdtmpdir {|d|
+ with_pipe {|r, w|
+ File.open("foe", "w+") {|f|
+ f.write "abcd\n"
+ f.rewind
+ f.write "xy"
+ IO.copy_stream(f, w)
+ }
+ assert_equal("xycd\n", File.read("foe"))
+ w.close
+ assert_equal("cd\n", r.read)
+ r.close
+ }
+ }
+ end
+
+ def test_copy_stream_dst_rbuf
+ mkcdtmpdir {|d|
+ with_pipe {|r, w|
+ w << "xyz"
+ w.close
+ File.open("fom", "w+") {|f|
+ f.write "abcd\n"
+ f.rewind
+ assert_equal("abc", f.read(3))
+ f.ungetc "c"
+ IO.copy_stream(r, f)
+ }
+ assert_equal("abxyz", File.read("fom"))
+ }
+ }
+ end
+
end