diff --git a/ChangeLog b/ChangeLog index 23712b0900..bcb131fa41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 15 17:28:30 2010 Yukihiro Matsumoto + + * io.c (rb_io_print): RDoc update. a patch from Daniel Kelley + in [ruby-core:28643]. + Mon Mar 15 14:06:07 2010 Nobuyoshi Nakada * random.c (next_state): no initialization here. diff --git a/io.c b/io.c index 6fd9f54d10..60afd6c3c7 100644 --- a/io.c +++ b/io.c @@ -5884,7 +5884,9 @@ rb_f_printf(int argc, VALUE *argv) * ios.print(obj, ...) => nil * * Writes the given object(s) to ios. The stream must be - * opened for writing. If the output record separator ($\\) + * opened for writing. If the output field separator ($,) + * is not nil, it will be inserted between each object. + * If the output record separator ($\\) * is not nil, it will be appended to the output. If no * arguments are given, prints $_. Objects that aren't * strings will be converted by calling their to_s method. diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a8860e1654..2da2ae95e6 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1396,6 +1396,23 @@ End assert_in_out_err(["-", t.path], "print while $<.gets", %w(foo bar baz), []) end + def test_print_separators + $, = ':' + $\ = "\n" + r, w = IO.pipe + w.print('a') + w.print('a','b','c') + w.close + assert_equal("a\n", r.gets) + assert_equal("a:b:c\n", r.gets) + assert_nil r.gets + r.close + + ensure + $, = nil + $\ = nil + end + def test_putc pipe(proc do |w| w.putc "A"