summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-20 04:59:04 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-20 04:59:04 +0000
commitb2e16548ef9253722272be11645b4a32a6d76032 (patch)
tree5d093538b21a26e91ce4d3100f0ba5841ccc715a /test/ruby/test_io.rb
parentbdeda0e6945521bc29b6a36bda9f410b2b82c8ca (diff)
downloadruby-b2e16548ef9253722272be11645b4a32a6d76032.tar.gz
ruby-b2e16548ef9253722272be11645b4a32a6d76032.tar.xz
ruby-b2e16548ef9253722272be11645b4a32a6d76032.zip
* io.c (copy_stream_fallback): write directly (bypassing write method)
if possible. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 1fa164566..e0c3c3d96 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -424,25 +424,30 @@ class TestIO < Test::Unit::TestCase
}
end
- def test_copy_stream_non_io
+ def test_copy_stream_fname_to_strio
mkcdtmpdir {|d|
- # filename to StringIO
File.open("foo", "w") {|f| f << "abcd" }
src = "foo"
dst = StringIO.new
ret = IO.copy_stream(src, dst, 3)
assert_equal(3, ret)
assert_equal("abc", dst.string)
+ }
+ end
+ def test_copy_stream_strio_to_fname
+ mkcdtmpdir {|d|
# StringIO to filename
src = StringIO.new("abcd")
- ret = File.open("fooo", "w") {|dst|
- IO.copy_stream(src, dst, 3)
- }
+ ret = IO.copy_stream(src, "fooo", 3)
assert_equal(3, ret)
- assert_equal("abc", dst.string)
+ assert_equal("abc", File.read("fooo"))
assert_equal(3, src.pos)
+ }
+ end
+ def test_copy_stream_io_to_strio
+ mkcdtmpdir {|d|
# IO to StringIO
File.open("bar", "w") {|f| f << "abcd" }
File.open("bar") {|src|
@@ -452,7 +457,11 @@ class TestIO < Test::Unit::TestCase
assert_equal("abc", dst.string)
assert_equal(3, src.pos)
}
+ }
+ end
+ def test_copy_stream_strio_to_io
+ mkcdtmpdir {|d|
# StringIO to IO
src = StringIO.new("abcd")
ret = File.open("baz", "w") {|dst|