Update ARGF.write
interface
This commit is contained in:
parent
64b0f4303e
commit
184db1fd6a
10
io.c
10
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);
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user