ruby-changes:19627
From: kosaki <ko1@a...>
Date: Sat, 21 May 2011 23:11:15 +0900 (JST)
Subject: [ruby-changes:19627] kosaki:r31671 (trunk): * io.c (rb_io_extract_modeenc): accept combination hash and
kosaki 2011-05-21 22:20:43 +0900 (Sat, 21 May 2011) New Revision: 31671 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31671 Log: * io.c (rb_io_extract_modeenc): accept combination hash and File::Constants. (eg. File.open('yo', :mode => File::WRONLY)) [Feature #4742][ruby-core:36338] * test/ruby/test_io.rb (TestIO#test_open_mode): new test. Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31670) +++ ChangeLog (revision 31671) @@ -1,3 +1,10 @@ +Sat May 21 22:14:35 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * io.c (rb_io_extract_modeenc): accept combination hash and + File::Constants. (eg. File.open('yo', :mode => File::WRONLY)) + [Feature #4742][ruby-core:36338] + * test/ruby/test_io.rb (TestIO#test_open_mode): new test. + Sat May 21 21:44:14 2011 Tadayoshi Funaba <tadf@d...> * test/date/test_switch_hitter.rb: new. Index: io.c =================================================================== --- io.c (revision 31670) +++ io.c (revision 31671) @@ -4458,6 +4458,7 @@ /* Set to defaults */ rb_io_ext_int_to_encs(NULL, NULL, &enc, &enc2); + vmode_handle: if (NIL_P(vmode)) { fmode = FMODE_READABLE | DEFAULT_TEXTMODE; oflags = O_RDONLY; @@ -4470,7 +4471,6 @@ else { const char *p; - vmode_handle: SafeStringValue(vmode); p = StringValueCStr(vmode); fmode = rb_io_modestr_fmode(p); Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 31670) +++ test/ruby/test_io.rb (revision 31671) @@ -1849,4 +1849,16 @@ end rescue NotImplementedError end + + def test_open_mode + feature4742 = "[ruby-core:36338]" + + mkcdtmpdir do + refute_nil(File.open('symbolic', 'w')) + refute_nil(File.open('numeric', File::WRONLY|File::TRUNC|File::CREAT)) + refute_nil(File.open('hash-symbolic', :mode => 'w')) + refute_nil(File.open('hash-numeric', :mode => File::WRONLY|File::TRUNC|File::CREAT), feature4742) + end + end + end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/