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
This commit is contained in:
parent
85e83e9f93
commit
87a9dcf1b6
@ -371,20 +371,20 @@ class TestDir_M17N < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
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
|
def test_entries_compose
|
||||||
bug7267 = '[ruby-core:48745] [Bug #7267]'
|
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|
|
with_tmpdir {|d|
|
||||||
orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
|
orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
|
||||||
orig.each {|n| open(n, "w") {}}
|
orig.each {|n| open(n, "w") {}}
|
||||||
if /mswin|mingw/ =~ RUBY_PLATFORM
|
if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||||
opts = {:encoding => Encoding.default_external}
|
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
|
else
|
||||||
enc = Encoding.find("filesystem")
|
enc = Encoding.find("filesystem")
|
||||||
enc = Encoding::ASCII_8BIT if enc == Encoding::US_ASCII
|
enc = Encoding::ASCII_8BIT if enc == Encoding::US_ASCII
|
||||||
@ -392,17 +392,28 @@ class TestDir_M17N < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
ents = Dir.entries(".", opts).reject {|n| /\A\./ =~ n}
|
ents = Dir.entries(".", opts).reject {|n| /\A\./ =~ n}
|
||||||
ents.sort!
|
ents.sort!
|
||||||
pp.assert_equal(orig, ents, bug7267)
|
PP.assert_equal(orig, ents, bug7267)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pwd
|
def test_pwd
|
||||||
with_tmpdir {|d|
|
orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
|
||||||
orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
|
expected = []
|
||||||
orig.each do |n|
|
results = []
|
||||||
Dir.mkdir(n)
|
orig.each {|o|
|
||||||
assert_equal(n, File.basename(Dir.chdir(n) {Dir.pwd}))
|
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
|
end
|
||||||
|
expected << n
|
||||||
|
with_tmpdir {
|
||||||
|
Dir.mkdir(o)
|
||||||
|
results << File.basename(Dir.chdir(o) {Dir.pwd})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
PP.assert_equal(expected, results)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user