From 3a4a494e024d010fb41e20d54d278ce37532db19 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 24 Jul 2012 03:14:31 +0000 Subject: * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_dir_m17n.rb | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0eea1bfef0..410eb55ab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 24 12:13:26 2012 NAKAMURA Usaku + + * 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 * test/ruby/test_pack.rb (test_pack_unpack_M): was redefined diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index ce5d4a864d..d9ff711435 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -28,8 +28,8 @@ class TestDir_M17N < Test::Unit::TestCase 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 @@ class TestDir_M17N < Test::Unit::TestCase 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 @@ class TestDir_M17N < Test::Unit::TestCase 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 @@ class TestDir_M17N < Test::Unit::TestCase 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 @@ class TestDir_M17N < Test::Unit::TestCase 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 -- cgit v1.2.3