From 3efa7126e5e853f06cdd78d4d88837aeb72a9a3e Mon Sep 17 00:00:00 2001 From: glass Date: Sun, 22 Oct 2017 02:11:07 +0000 Subject: 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 --- test/ruby/test_io.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/ruby/test_io.rb') 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 -- cgit v1.2.3