diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-14 08:20:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-14 08:20:26 +0000 |
commit | 99ad512486bc0a216d297e16f5346762230015e4 (patch) | |
tree | 630348515e1f28eac5865d28f67d1539774e1cbe /test/optparse/test_noarg.rb | |
parent | def1fbde5cd9586b3d661ded03ccd58183b78049 (diff) |
optparse.rb: hyphenize
* lib/optparse.rb (make_switch, parse_in_order): unify underscores
to hyphens.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/optparse/test_noarg.rb')
-rw-r--r-- | test/optparse/test_noarg.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/optparse/test_noarg.rb b/test/optparse/test_noarg.rb index 8f9be29ab8..8f20519408 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 |