diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-28 01:40:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-28 01:40:56 +0000 |
commit | 4a3c049cd1a02f3a650cec165178b33d8bfb0bfd (patch) | |
tree | 8d81b0c7da0ef2e5dae63538757654ab95d1a598 /test/ruby/test_io.rb | |
parent | 8940e3721010e8867242ecf72d23a647304581a1 (diff) | |
download | ruby-4a3c049cd1a02f3a650cec165178b33d8bfb0bfd.tar.gz |
io.c: IO#reopen int mode
* io.c (rb_io_reopen): accept File::Constants as well as mode string.
based on the patch by Glass_saga (Masaki Matsushita) in
[ruby-core:47694]. [Feature #7067]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index e266f115ba..4ee05911fb 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1713,6 +1713,25 @@ End } end + def test_reopen_mode + feature7067 = '[ruby-core:47694]' + make_tempfile {|t| + open(__FILE__) do |f| + assert_nothing_raised { + f.reopen(t.path, "r") + assert_equal("foo\n", f.gets) + } + end + + open(__FILE__) do |f| + assert_nothing_raised(feature7067) { + f.reopen(t.path, File::RDONLY) + assert_equal("foo\n", f.gets) + } + end + } + end + def test_foreach a = [] IO.foreach("|" + EnvUtil.rubybin + " -e 'puts :foo; puts :bar; puts :baz'") {|x| a << x } |