[前][次][番号順一覧][スレッド一覧]

ruby-changes:23563

From: tenderlove <ko1@a...>
Date: Fri, 11 May 2012 03:03:19 +0900 (JST)
Subject: [ruby-changes:23563] tenderlove:r35614 (trunk): adding a few tests surrounding file open arguments

tenderlove	2012-05-11 03:03:06 +0900 (Fri, 11 May 2012)

  New Revision: 35614

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35614

  Log:
    adding a few tests surrounding file open arguments

  Modified files:
    trunk/test/ruby/test_file.rb

Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 35613)
+++ test/ruby/test_file.rb	(revision 35614)
@@ -205,6 +205,36 @@
     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]'

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]