summaryrefslogtreecommitdiffstats
path: root/test/optparse/test_reqarg.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-21 03:23:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-21 03:23:19 +0000
commitb8a59c197d9b51f7746d37431bf5f2708a376aef (patch)
tree7219fc04e0c345839cb05b0f8cddb68ede50a82b /test/optparse/test_reqarg.rb
parent26f053db76fc5d01e765acec918e4fb9629bdb01 (diff)
downloadruby-b8a59c197d9b51f7746d37431bf5f2708a376aef.tar.gz
ruby-b8a59c197d9b51f7746d37431bf5f2708a376aef.tar.xz
ruby-b8a59c197d9b51f7746d37431bf5f2708a376aef.zip
* lib/optparse.rb (SPLAT_PROC): fix for regexp. [ruby-dev:37514]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/optparse/test_reqarg.rb')
-rw-r--r--test/optparse/test_reqarg.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/optparse/test_reqarg.rb b/test/optparse/test_reqarg.rb
index 4ce9dd629..579794695 100644
--- a/test/optparse/test_reqarg.rb
+++ b/test/optparse/test_reqarg.rb
@@ -60,4 +60,16 @@ module TestOptionParser::ReqArg
assert_equal(%w"", no_error {@opt.parse!(%w"--opt=foo")})
assert_equal("foo", @flag)
end
+
+ class TestOptionParser::WithPattern < TestOptionParser
+ def test_pattern
+ pat = num = nil
+ @opt.def_option("--pattern=VAL", /(\w+)(?:\s*:\s*(\w+))?/) {|x, y, z| pat = [x, y, z]}
+ @opt.def_option("-T NUM", /\A[1-4]\z/) {|n| num = n}
+ no_error {@opt.parse!(%w"--pattern=key:val")}
+ assert_equal(%w"key:val key val", pat, '[ruby-list:45645]')
+ no_error {@opt.parse!(%w"-T 4")}
+ assert_equal("4", num, '[ruby-dev:37514]')
+ end
+ end
end