summaryrefslogtreecommitdiff
path: root/test/optparse
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-06 08:23:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-06 08:23:10 +0000
commit49684589cdbbbec3d43b73c1255f9c16171b055d (patch)
treeb3fbc07ffeda4a61ca34f64dea679c4a533f0e79 /test/optparse
parent4d0e0a38239b7558f3f7934076b6e3dd54b1547f (diff)
optparse.rb: into kwdarg
* lib/optparse.rb (OptionParser#order!): add `into` optional keyword argument to store the results. [Feature #11191] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/optparse')
-rw-r--r--test/optparse/test_optparse.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb
index f17f8ee..a2540db 100644
--- a/test/optparse/test_optparse.rb
+++ b/test/optparse/test_optparse.rb
@@ -64,4 +64,15 @@ class TestOptionParser < Test::Unit::TestCase
assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/n")})
assert_equal(/foo/n, @reopt)
end
+
+ def test_into
+ @opt.def_option "-h", "--host=HOST", "hostname"
+ @opt.def_option "-p", "--port=PORT", "port", Integer
+ @opt.def_option "-v", "--verbose" do @verbose = true end
+ @opt.def_option "-q", "--quiet" do @quiet = true end
+ result = {}
+ @opt.parse %w(--host localhost --port 8000 -v), into: result
+ assert_equal({host: "localhost", port: 8000, verbose: true}, result)
+ assert_equal(true, @verbose)
+ end
end