diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-24 04:09:31 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-24 04:09:31 +0000 |
commit | 411fa093831957927dceae588fe3b9cd591ddd57 (patch) | |
tree | 3c508c9825b7642b7852e83ca4917ccda7d922e4 /test | |
parent | 353da8cccd6fdf47fc834ef95c48c95c62af38a6 (diff) |
merges r20895 and r20902 from trunk into ruby_1_9_1.
* lib/optparse.rb (SPLAT_PROC): fix for regexp. [ruby-dev:37514]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/optparse/test_reqarg.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/optparse/test_reqarg.rb b/test/optparse/test_reqarg.rb index 4ce9dd6292..579794695a 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 |