ruby-changes:22686
From: nobu <ko1@a...>
Date: Wed, 22 Feb 2012 17:07:48 +0900 (JST)
Subject: [ruby-changes:22686] nobu:r34735 (trunk): * io.c (rb_io_s_foreach): return enumerator including kerword
nobu 2012-02-22 17:07:38 +0900 (Wed, 22 Feb 2012) New Revision: 34735 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34735 Log: * io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054] Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34734) +++ ChangeLog (revision 34735) @@ -1,3 +1,8 @@ +Wed Feb 22 17:07:35 2012 Nobuyoshi Nakada <nobu@r...> + + * io.c (rb_io_s_foreach): return enumerator including kerword + arguments. [ruby-dev:45267][Bug #6054] + Wed Feb 22 15:47:04 2012 Nobuyoshi Nakada <nobu@r...> * common.mk (test-all): shut up nonsense skipping messages. Index: io.c =================================================================== --- io.c (revision 34734) +++ io.c (revision 34735) @@ -8971,8 +8971,8 @@ VALUE opt; struct foreach_arg arg; + RETURN_ENUMERATOR(self, argc, argv); argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt); - RETURN_ENUMERATOR(self, argc, argv); open_key_args(argc, argv, opt, &arg); if (NIL_P(arg.io)) return Qnil; return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io); Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 34734) +++ test/ruby/test_io.rb (revision 34735) @@ -1605,6 +1605,9 @@ IO.foreach(t.path, "b", 3) {|x| a << x } assert_equal(["foo", "\nb", "ar\n", "b", "az\n"], a) + bug6054 = '[ruby-dev:45267]' + e = assert_raise(IOError, bug6054) {IO.foreach(t.path, mode:"w").next} + assert_match(/not opened for reading/, e.message, bug6054) end def test_s_readlines -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/