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

ruby-changes:25497

From: usa <ko1@a...>
Date: Thu, 8 Nov 2012 14:45:29 +0900 (JST)
Subject: [ruby-changes:25497] usa:r37554 (ruby_1_9_3): merge revision(s) 36509,36514: [Backport #7294]

usa	2012-11-08 14:43:25 +0900 (Thu, 08 Nov 2012)

  New Revision: 37554

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

  Log:
    merge revision(s) 36509,36514: [Backport #7294]
    
    * test/ruby/test_dir_m17n.rb (create_and_check_raw_file_name): add new
      helper method to ease encoding testing. Patch by Oleg Sukhodolsky.
      [ruby-core:46589][Bug #6765]
    
    * test/ruby/test_dir_m17n.rb (test_filename_extutf8): use filesystem
      encoding when reading entries and comparing.
    
    * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_name): removed.
    
    * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_jp_name): split test.
    
    * test/ruby/test_dir_m17n.rb: refactoring. RE should be in the left side
      of the =~ operator, and compare the result with nil is meaningless.

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/test/ruby/test_dir_m17n.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 37553)
+++ ruby_1_9_3/ChangeLog	(revision 37554)
@@ -1,3 +1,21 @@
+Thu Nov  8 14:43:17 2012  NAKAMURA Usaku  <usa@r...>
+
+	* test/ruby/test_dir_m17n.rb: refactoring. RE should be in the left side
+	  of the =~ operator, and compare the result with nil is meaningless.
+
+Thu Nov  8 14:43:17 2012  Luis Lavena  <luislavena@g...>
+
+	* test/ruby/test_dir_m17n.rb (create_and_check_raw_file_name): add new
+	  helper method to ease encoding testing. Patch by Oleg Sukhodolsky.
+	  [ruby-core:46589][Bug #6765]
+
+	* test/ruby/test_dir_m17n.rb (test_filename_extutf8): use filesystem
+	  encoding when reading entries and comparing.
+
+	* test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_name): removed.
+
+	* test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_jp_name): split test.
+
 Thu Nov  8 14:16:53 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb (MakeMakefile#timestamp_file): use .-. instead of !, a
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 37553)
+++ ruby_1_9_3/version.h	(revision 37554)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 310
+#define RUBY_PATCHLEVEL 311
 
 #define RUBY_RELEASE_DATE "2012-11-08"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/test/ruby/test_dir_m17n.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_dir_m17n.rb	(revision 37553)
+++ ruby_1_9_3/test/ruby/test_dir_m17n.rb	(revision 37554)
@@ -11,6 +11,33 @@
     }
   end
 
+  def create_and_check_raw_file_name(code, encoding)
+    with_tmpdir { |dir|
+      create_file_program = %Q[
+        filename = #{code}.chr('UTF-8').force_encoding("#{encoding}")
+        File.open(filename, "w") {}
+        opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
+        ents = Dir.entries(".", opts)
+        exit ents.include?(filename)
+      ]
+      assert_ruby_status(["-E#{encoding}"], create_file_program, nil, :chdir=>dir)
+
+      test_file_program = %Q[
+        filename = #{code}.chr('UTF-8').force_encoding("ASCII-8BIT")
+        opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
+        ents = Dir.entries(".", opts)
+        expected_filename = #{code}.chr('UTF-8').encode(Encoding.find("filesystem")) rescue expected_filename = "?"
+        expected_filename = expected_filename.force_encoding("ASCII-8BIT")
+        result = ents.include?(filename) || (/mswin|mingw/ =~ RUBY_PLATFORM && ents.include?(expected_filename))
+        if !result && /mswin|mingw/ =~ RUBY_PLATFORM
+          exit Dir.entries(".", {:encoding => Encoding.find("filesystem")}).include?(expected_filename)
+        end
+        exit result
+      ]
+      assert_ruby_status(%w[-EASCII-8BIT], test_file_program, nil, :chdir=>dir)
+    }
+  end
+
   ## UTF-8 default_external, no default_internal
 
   def test_filename_extutf8
@@ -32,14 +59,14 @@
         File.open(filename, "w") {}
         opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
         ents = Dir.entries(".", opts)
-        exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF"))
+        exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%FF"))
       EOS
       assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
         filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8
         File.open(filename, "w") {}
         opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
         ents = Dir.entries(".", opts)
-        exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF"))
+        exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%FF"))
       EOS
     }
   end unless /mswin|mingw/ =~ RUBY_PLATFORM
@@ -153,7 +180,7 @@
         ents = Dir.entries(".", opts)
         ents.each {|e| e.force_encoding("ASCII-8BIT") }
         exit ents.include?(filename.force_encoding("ASCII-8BIT")) ||
-               ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT")))
+               (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("ASCII-8BIT")))
       EOS
     }
   end
@@ -165,37 +192,37 @@
         File.open(filename, "w") {}
         opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
         ents = Dir.entries(".", opts)
-        exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp")))
+        exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("euc-jp")))
       EOS
       assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
-        filename = "\xA4\xA2"
+        filename = "\xA4\xA2".force_encoding('ASCII-8BIT')
+        win_expected_filename = filename.encode(Encoding.find("filesystem")) rescue "?"
         opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
         ents = Dir.entries(".", opts)
-        exit ents.include?(filename) ||
-               ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ||
-               ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT")))
+        p ents
+        result = ents.include?(filename) ||
+               (/darwin/ =~ RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ||
+               (/mswin|mingw/ =~ RUBY_PLATFORM && ents.include?(win_expected_filename.force_encoding("ASCII-8BIT")))
+        if !result && /mswin|mingw/ =~ RUBY_PLATFORM
+          exit Dir.entries(".", {:encoding => Encoding.find("filesystem")}).include?(win_expected_filename)
+        end
+        exit result
       EOS
     }
   end
 
-  def test_filename_utf8_raw_name
-    with_tmpdir {|d|
-      assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
-        filename = "\u3042".force_encoding("utf-8")
-        File.open(filename, "w") {}
-        opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
-        ents = Dir.entries(".", opts)
-        exit ents.include?(filename)
-      EOS
-      assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
-        filename = "\u3042".force_encoding("ASCII-8BIT")
-        opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
-        ents = Dir.entries(".", opts)
-        exit ents.include?(filename) || ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT")))
-      EOS
-    }
+  def test_filename_utf8_raw_jp_name
+    create_and_check_raw_file_name(0x3042, "UTF-8")
   end
 
+  def test_filename_utf8_raw_windows_1251_name
+    create_and_check_raw_file_name(0x0424, "UTF-8")
+  end
+
+  def test_filename_utf8_raw_windows_1252_name
+    create_and_check_raw_file_name(0x00c7, "UTF-8")
+  end
+
   def test_filename_ext_euc_jp_and_int_utf_8
     with_tmpdir {|d|
       assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d)
@@ -203,13 +230,13 @@
         File.open(filename, "w") {}
         opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
         ents = Dir.entries(".", opts)
-        exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp")))
+        exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("euc-jp")))
       EOS
       assert_ruby_status(%w[-EEUC-JP:UTF-8], <<-'EOS', nil, :chdir=>d)
         filename = "\u3042"
         opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
         ents = Dir.entries(".", opts)
-        exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2"))
+        exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2"))
       EOS
     }
   end

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r36509,36514


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

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