summaryrefslogtreecommitdiff
path: root/test/optparse/test_noarg.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/optparse/test_noarg.rb')
-rw-r--r--test/optparse/test_noarg.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/optparse/test_noarg.rb b/test/optparse/test_noarg.rb
index 8f9be29ab86..8f205194083 100644
--- a/test/optparse/test_noarg.rb
+++ b/test/optparse/test_noarg.rb
@@ -2,6 +2,12 @@
require_relative 'test_optparse'
module TestOptionParser::NoArg
+ def setup
+ super
+ @opt.def_option "--with_underscore" do |x| @flag = x end
+ @opt.def_option "--with-hyphen" do |x| @flag = x end
+ end
+
class Def1 < TestOptionParser
include NoArg
def setup
@@ -55,4 +61,19 @@ module TestOptionParser::NoArg
assert_equal(%w"", no_error {@opt.parse!(%w"--opt")})
assert_equal(true, @flag)
end
+
+ def test_hyphenize
+ @flag = nil
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with_underscore")})
+ assert_equal(true, @flag)
+ @flag = nil
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with-underscore")})
+ assert_equal(true, @flag)
+ @flag = nil
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with-hyphen")})
+ assert_equal(true, @flag)
+ @flag = nil
+ assert_equal(%w"", no_error {@opt.parse!(%w"--with_hyphen")})
+ assert_equal(true, @flag)
+ end
end