1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_dir_m17n.rb: changes for windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2010-05-17 02:07:00 +00:00
parent fef3c0a415
commit 6b15bccfdf

View file

@ -18,25 +18,29 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\u3042" filename = "\u3042"
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename) exit ents.include?(filename)
EOS EOS
} }
end end
def test_filename_extutf8_invalid def test_filename_extutf8_invalid
skip "ruby on windows doesn't support invalid utf-8 path" if /mswin|mingw/ =~ RUBY_PLATFORM
with_tmpdir {|d| with_tmpdir {|d|
assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
filename = "\xff".force_encoding("ASCII-8BIT") # invalid byte sequence as UTF-8 filename = "\xff".force_encoding("ASCII-8BIT") # invalid byte sequence as UTF-8
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
exit ents.include?(filename) || (RUBY_PLATFORM =~ /darwin/ && ents.include?("%FF")) ents = Dir.entries(".", opts)
exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF"))
EOS EOS
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8 filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
exit ents.include?(filename) || (RUBY_PLATFORM =~ /darwin/ && ents.include?("%FF")) ents = Dir.entries(".", opts)
exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF"))
EOS EOS
} }
end end
@ -46,11 +50,16 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\xc2\xa1".force_encoding("utf-8") filename = "\xc2\xa1".force_encoding("utf-8")
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename) exit ents.include?(filename)
EOS EOS
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\xc2\xa1".force_encoding("euc-jp") if /mswin|mingw/ =~ RUBY_PLATFORM
filename = "\x8f\xa2\xc2".force_encoding("euc-jp")
else
filename = "\xc2\xa1".force_encoding("euc-jp")
end
begin begin
open(filename) {} open(filename) {}
exit true exit true
@ -58,6 +67,7 @@ class TestDir_M17N < Test::Unit::TestCase
exit false exit false
end end
EOS EOS
skip "no meaning test on windows" if /mswin|mingw/ =~ RUBY_PLATFORM
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename1 = "\xc2\xa1".force_encoding("utf-8") filename1 = "\xc2\xa1".force_encoding("utf-8")
filename2 = "\xc2\xa1".force_encoding("euc-jp") filename2 = "\xc2\xa1".force_encoding("euc-jp")
@ -79,12 +89,14 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\u3042" filename = "\u3042"
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename) exit ents.include?(filename)
EOS EOS
assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d)
filename = "\xA4\xA2".force_encoding("euc-jp") filename = "\xA4\xA2".force_encoding("euc-jp")
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename) exit ents.include?(filename)
EOS EOS
assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d)
@ -106,13 +118,15 @@ class TestDir_M17N < Test::Unit::TestCase
filename2 = "\u3042" # HIRAGANA LETTER A which is representable in EUC-JP filename2 = "\u3042" # HIRAGANA LETTER A which is representable in EUC-JP
File.open(filename1, "w") {} File.open(filename1, "w") {}
File.open(filename2, "w") {} File.open(filename2, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename1) && ents.include?(filename2) exit ents.include?(filename1) && ents.include?(filename2)
EOS EOS
assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d)
filename1 = "\u2661" # WHITE HEART SUIT which is not representable in EUC-JP filename1 = "\u2661" # WHITE HEART SUIT which is not representable in EUC-JP
filename2 = "\xA4\xA2".force_encoding("euc-jp") # HIRAGANA LETTER A in EUC-JP filename2 = "\xA4\xA2".force_encoding("euc-jp") # HIRAGANA LETTER A in EUC-JP
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename1) && ents.include?(filename2) exit ents.include?(filename1) && ents.include?(filename2)
EOS EOS
assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS', nil, :chdir=>d)
@ -134,10 +148,11 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d)
filename = "\xA4\xA2".force_encoding("euc-jp") filename = "\xA4\xA2".force_encoding("euc-jp")
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
ents.each {|e| e.force_encoding("ASCII-8BIT") } ents.each {|e| e.force_encoding("ASCII-8BIT") }
exit ents.include?(filename.force_encoding("ASCII-8BIT")) || exit ents.include?(filename.force_encoding("ASCII-8BIT")) ||
(RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT")))
EOS EOS
} }
end end
@ -147,15 +162,17 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d)
filename = "\xA4\xA2".force_encoding("euc-jp") filename = "\xA4\xA2".force_encoding("euc-jp")
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
exit ents.include?(filename) || ents = Dir.entries(".", opts)
(RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2".force_encoding("euc-jp"))) exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp")))
EOS EOS
assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
filename = "\xA4\xA2" filename = "\xA4\xA2"
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename) || exit ents.include?(filename) ||
(RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ((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")))
EOS EOS
} }
end end
@ -165,13 +182,15 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\u3042".force_encoding("utf-8") filename = "\u3042".force_encoding("utf-8")
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
exit ents.include?(filename) exit ents.include?(filename)
EOS EOS
assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
filename = "\u3042".force_encoding("ASCII-8BIT") filename = "\u3042".force_encoding("ASCII-8BIT")
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
exit ents.include?(filename) ents = Dir.entries(".", opts)
exit ents.include?(filename) || ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT")))
EOS EOS
} }
end end
@ -181,14 +200,15 @@ class TestDir_M17N < Test::Unit::TestCase
assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EEUC-JP], <<-'EOS', nil, :chdir=>d)
filename = "\xA4\xA2".force_encoding("euc-jp") filename = "\xA4\xA2".force_encoding("euc-jp")
File.open(filename, "w") {} File.open(filename, "w") {}
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
exit ents.include?(filename) || ents = Dir.entries(".", opts)
(RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2".force_encoding("euc-jp"))) exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp")))
EOS EOS
assert_ruby_status(%w[-EEUC-JP:UTF-8], <<-'EOS', nil, :chdir=>d) assert_ruby_status(%w[-EEUC-JP:UTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\u3042" filename = "\u3042"
ents = Dir.entries(".") opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
exit ents.include?(filename) || (RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2")) ents = Dir.entries(".", opts)
exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2"))
EOS EOS
} }
end end