summaryrefslogtreecommitdiff
path: root/test/ruby/test_dir.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-05 04:30:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-05 04:30:10 +0000
commit83185f9181e90979dd698489cefd85514661265e (patch)
treee5e23b380ecd882baa5986508e9ab75b20dc3647 /test/ruby/test_dir.rb
parentf1df537a831c57021508ac9ca03229550d99b4d8 (diff)
dir.c: fix recursion
* dir.c (glob_make_pattern): names under recursive need to be single basenames to match for each name. [ruby-core:47418] [Bug #6977] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r--test/ruby/test_dir.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index e385072eec..21902298c0 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -166,6 +166,20 @@ class TestDir < Test::Unit::TestCase
assert_equal((?a..?f).map {|f| File.join(@root, f) }.sort, Dir.glob(File.join(@root, '[abc/def]')).sort)
end
+ def test_glob_recursive
+ bug6977 = '[ruby-core:47418]'
+ Dir.chdir(@root) do
+ FileUtils.mkdir_p("a/b/c/d/e/f")
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/e/f"), bug6977)
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/d/e/f"), bug6977)
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/d/e/f"), bug6977)
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/b/c/d/e/f"), bug6977)
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/?/e/f"), bug6977)
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977)
+ assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977)
+ end
+ end
+
def test_foreach
assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a)
end