aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 02:11:07 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 02:11:07 +0000
commit3efa7126e5e853f06cdd78d4d88837aeb72a9a3e (patch)
treefa2748abd042a5a53a305d2c275a1f544b0102ab /test/ruby/test_io.rb
parentb52cdd2b44c9e109048c0ad71842b361b658a0ee (diff)
downloadruby-3efa7126e5e853f06cdd78d4d88837aeb72a9a3e.tar.gz
Make IO#write accept multiple arguments
io.c: make IO#write accept multiple arguments. it uses writev(2) if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 402d497896..c7c4129e3e 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1216,6 +1216,32 @@ class TestIO < Test::Unit::TestCase
end)
end
+ def test_write_with_multiple_arguments
+ pipe(proc do |w|
+ w.write("foo", "bar")
+ w.close
+ end, proc do |r|
+ assert_equal("foobar", r.read)
+ end)
+ end
+
+ def test_write_with_many_arguments
+ pipe(proc do |w|
+ w.write(*(["a"] * 1023))
+ w.close
+ end, proc do |r|
+ assert_equal("a" * 1023, r.read)
+ end)
+ end
+
+ def test_write_with_too_many_arguments
+ with_pipe do |r, w|
+ assert_raise(ArgumentError) do
+ w.write(*(["a"] * 1024))
+ end
+ end
+ end
+
def test_write_non_writable
with_pipe do |r, w|
assert_raise(IOError) do