summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-10 08:49:54 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-10 08:49:54 +0000
commit2c490bea5b4eb31ae20386bc88d46d2ff432f407 (patch)
treebcb3704feecdfca08f8dd273ed5a359861089bab /test
parent1a7e21943307a21cc3a70237a85ff7205d6dcd53 (diff)
merge revision(s) 55228: [Backport #12438]
* lib/optparse.rb (OptionParser::Completion.candidate): get rid of nil as key names. [ruby-core:75773] [Bug #12438] * lib/optparse.rb (OptionParser#make_switch): char class option cannot be NoArgument, default to RequiredArgument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@55364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/optparse/test_cclass.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/optparse/test_cclass.rb b/test/optparse/test_cclass.rb
new file mode 100644
index 0000000000..ac46f46bb2
--- /dev/null
+++ b/test/optparse/test_cclass.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: false
+require_relative 'test_optparse'
+
+class TestOptionParser::CClass < TestOptionParser
+ def test_no_argument
+ flags = []
+ @opt.def_option("-[a-z]") {|x| flags << x}
+ no_error {@opt.parse!(%w"-a")}
+ assert_equal(%w"a", flags)
+ end
+
+ def test_required_argument
+ flags = []
+ @opt.def_option("-[a-z]X") {|x| flags << x}
+ no_error {@opt.parse!(%w"-a")}
+ assert_equal(%w"a", flags)
+ end
+end