diff options
-rw-r--r-- | test/ruby/test_dir_m17n.rb | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index 1d051143ae..4063c834de 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -371,20 +371,20 @@ class TestDir_M17N < Test::Unit::TestCase end end + PP = Object.new.extend(Test::Unit::Assertions) + def PP.mu_pp(ary) #:nodoc: + '[' << ary.map {|str| "#{str.dump}(#{str.encoding})"}.join(', ') << ']' + end + def test_entries_compose bug7267 = '[ruby-core:48745] [Bug #7267]' - pp = Object.new.extend(Test::Unit::Assertions) - def pp.mu_pp(ary) #:nodoc: - '[' << ary.map {|str| "#{str.dump}(#{str.encoding})"}.join(', ') << ']' - end - with_tmpdir {|d| orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}" orig.each {|n| open(n, "w") {}} if /mswin|mingw/ =~ RUBY_PLATFORM opts = {:encoding => Encoding.default_external} - orig.map! {|o| o.encode(Encoding.find("filesystem")) rescue o.tr("^a-z", "?")} + orig.map! {|o| o.encode("filesystem") rescue o.tr("^a-z", "?")} else enc = Encoding.find("filesystem") enc = Encoding::ASCII_8BIT if enc == Encoding::US_ASCII @@ -392,17 +392,28 @@ class TestDir_M17N < Test::Unit::TestCase end ents = Dir.entries(".", opts).reject {|n| /\A\./ =~ n} ents.sort! - pp.assert_equal(orig, ents, bug7267) + PP.assert_equal(orig, ents, bug7267) } end def test_pwd - with_tmpdir {|d| - orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}" - orig.each do |n| - Dir.mkdir(n) - assert_equal(n, File.basename(Dir.chdir(n) {Dir.pwd})) + orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}" + expected = [] + results = [] + orig.each {|o| + if /mswin|mingw/ =~ RUBY_PLATFORM + n = (o.encode("filesystem") rescue next) + else + enc = Encoding.find("filesystem") + enc = Encoding::ASCII_8BIT if enc == Encoding::US_ASCII + n = o.dup.force_encoding(enc) end + expected << n + with_tmpdir { + Dir.mkdir(o) + results << File.basename(Dir.chdir(o) {Dir.pwd}) + } } + PP.assert_equal(expected, results) end end |