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

ruby-changes:24463

From: usa <ko1@a...>
Date: Tue, 24 Jul 2012 12:14:44 +0900 (JST)
Subject: [ruby-changes:24463] usa:r36514 (trunk): * test/ruby/test_dir_m17n.rb: refactoring. RE should be in the left side

usa	2012-07-24 12:14:31 +0900 (Tue, 24 Jul 2012)

  New Revision: 36514

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

  Log:
    * 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 files:
    trunk/ChangeLog
    trunk/test/ruby/test_dir_m17n.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36513)
+++ ChangeLog	(revision 36514)
@@ -1,3 +1,8 @@
+Tue Jul 24 12:13:26 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.
+
 Tue Jul 24 11:35:20 2012  NAKAMURA Usaku  <usa@r...>
 
 	* test/ruby/test_pack.rb (test_pack_unpack_M): was redefined
Index: test/ruby/test_dir_m17n.rb
===================================================================
--- test/ruby/test_dir_m17n.rb	(revision 36513)
+++ test/ruby/test_dir_m17n.rb	(revision 36514)
@@ -28,8 +28,8 @@
         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) || ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?(expected_filename))
-        if !result &&  ((RUBY_PLATFORM =~ /mswin|mingw/) != nil)
+        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
@@ -59,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
@@ -180,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
@@ -192,17 +192,18 @@
         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".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)
+        p ents
         result = ents.include?(filename) ||
-               ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ||
-               ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?(win_expected_filename.force_encoding("ASCII-8BIT")))
-        if !result &&  ((RUBY_PLATFORM =~ /mswin|mingw/) != nil)
+               (/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
@@ -229,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

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

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