diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-19 08:33:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-19 08:33:01 +0000 |
commit | 0820c654b26dd36145d1bd394ea58df80fc54918 (patch) | |
tree | 41ff49eb0653e30f6bc38db85622553228faf8c0 /test | |
parent | 3dd4ff97ccf4d77a781d5523e8f89f8f261d0e4d (diff) | |
download | ruby-0820c654b26dd36145d1bd394ea58df80fc54918.tar.gz ruby-0820c654b26dd36145d1bd394ea58df80fc54918.tar.xz ruby-0820c654b26dd36145d1bd394ea58df80fc54918.zip |
* dir.c (GlobPathValue), file.c (rb_get_path_check): path names
must be ASCII compatible.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_dir.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 0ea28f55d..eb315d3d8 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -161,6 +161,11 @@ class TestDir < Test::Unit::TestCase Dir.glob(File.join(@root, '{\{\},a}'))) assert_equal([], Dir.glob(File.join(@root, '['))) assert_equal([], Dir.glob(File.join(@root, '[a-\\'))) + + d = "\u{3042}\u{3044}".encode("utf-16le") + assert_raise(Encoding::CompatibilityError) {Dir.glob(d)} + m = Class.new {define_method(:to_path) {d}} + assert_raise(Encoding::CompatibilityError) {Dir.glob(m.new)} end def test_foreach diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 881edb57a..e7d60960b 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -3,6 +3,13 @@ require "fileutils" require "tmpdir" class TestFileExhaustive < Test::Unit::TestCase + def assert_incompatible_encoding + d = "\u{3042}\u{3044}".encode("utf-16le") + assert_raise(Encoding::CompatibilityError) {yield d} + m = Class.new {define_method(:to_path) {d}} + assert_raise(Encoding::CompatibilityError) {yield m.new} + end + def setup @dir = Dir.mktmpdir("rubytest-file") File.chown(-1, Process.gid, @dir) @@ -388,6 +395,8 @@ class TestFileExhaustive < Test::Unit::TestCase assert_kind_of(String, File.expand_path("~")) assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") } assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") } + + assert_incompatible_encoding {|d| File.expand_path(d)} end def test_basename @@ -412,11 +421,14 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(basename, File.basename(@file + ".", ".*")) assert_equal(basename, File.basename(@file + "::$DATA", ".*")) end + + assert_incompatible_encoding {|d| File.basename(d)} end def test_dirname assert(@file.start_with?(File.dirname(@file))) assert_equal(".", File.dirname("")) + assert_incompatible_encoding {|d| File.dirname(d)} end def test_extname @@ -440,6 +452,8 @@ class TestFileExhaustive < Test::Unit::TestCase end end end + + assert_incompatible_encoding {|d| File.extname(d)} end def test_split |