mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
040207ea01
commit
3a4a494e02
2 changed files with 17 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Jul 24 12:13:26 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_pack.rb (test_pack_unpack_M): was redefined
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue