diff options
author | Junichi Ito <jit@sonicgarden.jp> | 2022-11-29 08:07:47 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-12-26 15:09:21 +0900 |
commit | cea6951ecf31b1d4e93d102cc8f08822470d4d1a (patch) | |
tree | 85ee9e9de3a38e21ea1cea6b373c2c68435239f0 /test/optparse | |
parent | 4c767c1354038804abd1c94e7f549ed4f95a3d31 (diff) | |
download | ruby-cea6951ecf31b1d4e93d102cc8f08822470d4d1a.tar.gz |
[ruby/optparse] Add symbolize_names to getopts
https://github.com/ruby/optparse/commit/3e63d878f8
Diffstat (limited to 'test/optparse')
-rw-r--r-- | test/optparse/test_getopts.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/optparse/test_getopts.rb b/test/optparse/test_getopts.rb index 7d9160f7af..4a0ae284e7 100644 --- a/test/optparse/test_getopts.rb +++ b/test/optparse/test_getopts.rb @@ -11,23 +11,39 @@ class TestOptionParserGetopts < Test::Unit::TestCase o = @opt.getopts(%w[-a], "ab") assert_equal(true, o['a']) assert_equal(false, o['b']) + + o = @opt.getopts(%w[-a], "ab", symbolize_names: true) + assert_equal(true, o[:a]) + assert_equal(false, o[:b]) end def test_short_arg o = @opt.getopts(%w[-a1], "a:b:") assert_equal("1", o['a']) assert_equal(nil, o['b']) + + o = @opt.getopts(%w[-a1], "a:b:", symbolize_names: true) + assert_equal("1", o[:a]) + assert_equal(nil, o[:b]) end def test_long_noarg o = @opt.getopts(%w[--foo], "", "foo", "bar") assert_equal(true, o['foo']) assert_equal(false, o['bar']) + + o = @opt.getopts(%w[--foo], "", "foo", "bar", symbolize_names: true) + assert_equal(true, o[:foo]) + assert_equal(false, o[:bar]) end def test_long_arg o = @opt.getopts(%w[--bar ZOT], "", "foo:FOO", "bar:BAR") assert_equal("FOO", o['foo']) assert_equal("ZOT", o['bar']) + + o = @opt.getopts(%w[--bar ZOT], "", "foo:FOO", "bar:BAR", symbolize_names: true) + assert_equal("FOO", o[:foo]) + assert_equal("ZOT", o[:bar]) end end |