diff --git a/io.c b/io.c index f773de8c3f..feff445943 100644 --- a/io.c +++ b/io.c @@ -14571,14 +14571,14 @@ argf_write_io(VALUE argf) /* * call-seq: - * ARGF.write(string) -> integer + * ARGF.write(*objects) -> integer * - * Writes _string_ if inplace mode. + * Writes each of the given +objects+ if inplace mode. */ static VALUE -argf_write(VALUE argf, VALUE str) +argf_write(int argc, VALUE *argv, VALUE argf) { - return rb_io_write(argf_write_io(argf), str); + return rb_io_writev(argf_write_io(argf), argc, argv); } void @@ -15823,7 +15823,7 @@ Init_IO(void) rb_define_method(rb_cARGF, "binmode", argf_binmode_m, 0); rb_define_method(rb_cARGF, "binmode?", argf_binmode_p, 0); - rb_define_method(rb_cARGF, "write", argf_write, 1); + rb_define_method(rb_cARGF, "write", argf_write, -1); rb_define_method(rb_cARGF, "print", rb_io_print, -1); rb_define_method(rb_cARGF, "putc", rb_io_putc, 1); rb_define_method(rb_cARGF, "puts", rb_io_puts, -1); diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index 146463a470..55a06296aa 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -1130,9 +1130,11 @@ class TestArgf < Test::Unit::TestCase def test_puts t = make_tempfile("argf-#{__method__}", 'bar') - ruby('-pi-', '-W0', '-e', "print ARGF.puts('foo')", t.path) do |f| + err = "#{@tmpdir}/errout" + ruby('-pi-', '-W2', '-e', "print ARGF.puts('foo')", t.path, {err: err}) do |f| end assert_equal("foo\nbar\n", File.read(t.path)) + assert_empty File.read(err) end def test_print