summaryrefslogtreecommitdiff
path: root/test/ruby/test_dir_m17n.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-18 13:02:28 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-18 13:02:28 +0000
commit1e7f2caa1f4f823d128261df4441c9e30236bc4a (patch)
tree1c964f0449fb6bcb0fd93c1000034b188f83e685 /test/ruby/test_dir_m17n.rb
parent4c6eda226aeee4896c3dfc1ca6c2cacfc9788d27 (diff)
add test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_dir_m17n.rb')
-rw-r--r--test/ruby/test_dir_m17n.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb
index 44a421874d..59feb2b089 100644
--- a/test/ruby/test_dir_m17n.rb
+++ b/test/ruby/test_dir_m17n.rb
@@ -41,6 +41,37 @@ class TestDir_M17N < Test::Unit::TestCase
}
end
+ def test_filename_as_bytes_extutf8
+ with_tmpdir {|d|
+ assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
+ filename = "\xc2\xa1".force_encoding("utf-8")
+ File.open(filename, "w") {}
+ ents = Dir.entries(".")
+ exit ents.include?(filename)
+ EOS
+ assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
+ filename = "\xc2\xa1".force_encoding("euc-jp")
+ begin
+ open(filename) {}
+ exit true
+ rescue Errno::ENOENT
+ exit false
+ end
+ EOS
+ assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
+ filename1 = "\xc2\xa1".force_encoding("utf-8")
+ filename2 = "\xc2\xa1".force_encoding("euc-jp")
+ filename3 = filename1.encode("euc-jp")
+ filename4 = filename2.encode("utf-8")
+ s1 = File.stat(filename1) rescue nil
+ s2 = File.stat(filename2) rescue nil
+ s3 = File.stat(filename3) rescue nil
+ s4 = File.stat(filename4) rescue nil
+ exit (s1 && s2 && !s3 && !s4) ? true : false
+ EOS
+ }
+ end
+
## UTF-8 default_external, EUC-JP default_internal
def test_filename_extutf8_inteucjp_representable