summaryrefslogtreecommitdiff
path: root/test/ruby/test_file.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-10 18:03:06 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-10 18:03:06 +0000
commit64c73b501bd45040a37436804e3e0c8d5baf0851 (patch)
tree3cb5715ff6a9b0e3e9f18dd2f31be4c512a1d41d /test/ruby/test_file.rb
parentbfbf9d0956e05fb3b8d1025f21414d6ef7a3693e (diff)
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
Diffstat (limited to 'test/ruby/test_file.rb')
-rw-r--r--test/ruby/test_file.rb30
1 files changed, 30 insertions, 0 deletions
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]'