diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-04 02:18:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-04 02:18:58 +0000 |
commit | 87a9dcf1b6b8ac1e5580004cad899f3757f3c24d (patch) | |
tree | 706dca72cbe6a02f5a3cb4a9ea9248f8a82effc4 /test/ruby | |
parent | 85e83e9f93f5d2acd25f22f761f8525ac75b5ec0 (diff) | |
download | ruby-87a9dcf1b6b8ac1e5580004cad899f3757f3c24d.tar.gz |
test_dir_m17n.rb: fix test
* test/ruby/test_dir_m17n.rb (test_pwd): fix test on some
platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-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 |