From e59d5667c7769ffbe77f50687cb4393ca9280b2b Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 4 Nov 2012 01:19:11 +0000 Subject: dir.c: FNM_EXTGLOB * dir.c (file_s_fnmatch): match with expanding braces if FNM_EXTGLOB is set. [ruby-core:40037] [Feature #5422] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 7 ++++++- test/ruby/test_fnmatch.rb | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'test/ruby') diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 3e04f55c0c..780196a438 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -229,7 +229,7 @@ module Test AssertFile end - class << (AssertFile = Object.new) + class << (AssertFile = Struct.new(:message).new) include Assertions def assert_file_predicate(predicate, *args) if /\Anot_/ =~ predicate @@ -241,9 +241,14 @@ module Test mesg = "Expected file " << args.shift.inspect mesg << mu_pp(args) unless args.empty? mesg << "#{neg} to be #{predicate}" + mesg << " #{message}" if message assert(result, mesg) end alias method_missing assert_file_predicate + + def for(message) + clone.tap {|a| a.message = message} + end end end end diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb index e5f5ba6a4f..d186638a7b 100644 --- a/test/ruby/test_fnmatch.rb +++ b/test/ruby/test_fnmatch.rb @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestFnmatch < Test::Unit::TestCase @@ -103,4 +104,9 @@ class TestFnmatch < Test::Unit::TestCase assert(File.fnmatch('**/foo', 'c:/root/foo', File::FNM_PATHNAME)) end + def test_extglob + feature5422 = '[ruby-core:40037]' + assert_file.for(feature5422).not_fnmatch?( "{.g,t}*", ".gem") + assert_file.for(feature5422).fnmatch?("{.g,t}*", ".gem", File::FNM_EXTGLOB) + end end -- cgit v1.2.3