summaryrefslogtreecommitdiff
path: root/test/optparse/test_reqarg.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/optparse/test_reqarg.rb')
-rw-r--r--test/optparse/test_reqarg.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/optparse/test_reqarg.rb b/test/optparse/test_reqarg.rb
index 1904f461549..b2e4755f80b 100644
--- a/test/optparse/test_reqarg.rb
+++ b/test/optparse/test_reqarg.rb
@@ -2,6 +2,12 @@
require_relative 'test_optparse'
module TestOptionParser::ReqArg
+ def setup
+ super
+ @opt.def_option "--with_underscore=VAL" do |x| @flag = x end
+ @opt.def_option "--with-hyphen=VAL" do |x| @flag = x end
+ end
+
class Def1 < TestOptionParser
include ReqArg
def setup
@@ -64,6 +70,17 @@ module TestOptionParser::ReqArg
assert_equal("foo", @flag)
end
+ def test_hyphenize
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with_underscore foo1")})
+ assert_equal("foo1", @flag)
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with-underscore foo2")})
+ assert_equal("foo2", @flag)
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with-hyphen foo3")})
+ assert_equal("foo3", @flag)
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with_hyphen foo4")})
+ assert_equal("foo4", @flag)
+ end
+
class TestOptionParser::WithPattern < TestOptionParser
def test_pattern
pat = num = nil