summaryrefslogtreecommitdiff
path: root/test/ruby/test_fnmatch.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-23 00:48:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-23 00:48:44 +0000
commit3331d6774f355e261644d7042cdeee0f03db3bc8 (patch)
tree70a5eaf2c74e09287324337f6c099b5e5bef9d10 /test/ruby/test_fnmatch.rb
parent143a2f7ef1a16e22709af87a227e9a6323aefd84 (diff)
dir.c: encoding check
* dir.c (file_s_fnmatch, fnmatch_brace): encoding-incompatible pattern and string do not match, instead of exception. [ruby-dev:47069] [Bug #7911] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_fnmatch.rb')
-rw-r--r--test/ruby/test_fnmatch.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb
index d186638a7b..0b3f604df5 100644
--- a/test/ruby/test_fnmatch.rb
+++ b/test/ruby/test_fnmatch.rb
@@ -109,4 +109,19 @@ class TestFnmatch < Test::Unit::TestCase
assert_file.for(feature5422).not_fnmatch?( "{.g,t}*", ".gem")
assert_file.for(feature5422).fnmatch?("{.g,t}*", ".gem", File::FNM_EXTGLOB)
end
+
+ def test_unmatched_encoding
+ bug7911 = '[ruby-dev:47069] [Bug #7911]'
+ path = "\u{3042}"
+ pattern_ascii = 'a'.encode('US-ASCII')
+ pattern_eucjp = path.encode('EUC-JP')
+ assert_nothing_raised(ArgumentError, bug7911) do
+ assert(!File.fnmatch(pattern_ascii, path))
+ assert(!File.fnmatch(pattern_eucjp, path))
+ assert(!File.fnmatch(pattern_ascii, path, File::FNM_CASEFOLD))
+ assert(!File.fnmatch(pattern_eucjp, path, File::FNM_CASEFOLD))
+ assert(File.fnmatch("{*,#{pattern_ascii}}", path, File::FNM_EXTGLOB))
+ assert(File.fnmatch("{*,#{pattern_eucjp}}", path, File::FNM_EXTGLOB))
+ end
+ end
end