mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a04e4ae82b
commit
67cf354b46
3 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat May 21 22:14:35 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||
|
||||
* 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@dotrb.org>
|
||||
|
||||
* test/date/test_switch_hitter.rb: new.
|
||||
|
|
2
io.c
2
io.c
|
@ -4458,6 +4458,7 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
|
|||
/* 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 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
|
|||
else {
|
||||
const char *p;
|
||||
|
||||
vmode_handle:
|
||||
SafeStringValue(vmode);
|
||||
p = StringValueCStr(vmode);
|
||||
fmode = rb_io_modestr_fmode(p);
|
||||
|
|
|
@ -1849,4 +1849,16 @@ End
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue