From 64c73b501bd45040a37436804e3e0c8d5baf0851 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Thu, 10 May 2012 18:03:06 +0000 Subject: adding a few tests surrounding file open arguments git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_file.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index bf2562317b..68dc7c1a1d 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -205,6 +205,36 @@ class TestFile < Test::Unit::TestCase end end + def test_file_open_permissions + Dir.mktmpdir(__method__.to_s) do |tmpdir| + File.open('x', :mode => IO::RDWR | IO::CREAT | IO::BINARY, + :encoding => Encoding::ASCII_8BIT) do |x| + + assert x.autoclose? + assert_equal Encoding::ASCII_8BIT, x.external_encoding + assert x.write 'hello' + + x.seek 0, IO::SEEK_SET + + assert_equal 'hello', x.read + + end + end + end + + def test_file_open_double_mode + e = assert_raises(ArgumentError) { File.open("a", 'w', :mode => 'rw+') } + assert_equal 'mode specified twice', e.message + end + + def test_conflicting_encodings + Dir.mktmpdir(__method__.to_s) do |tmpdir| + File.open('x', 'wb', :encoding => Encoding::EUC_JP) do |x| + assert_equal Encoding::EUC_JP, x.external_encoding + end + end + end + if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM def test_long_unc feature3399 = '[ruby-core:30623]' -- cgit v1.2.3