1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/optparse/test_cclass.rb
nagachika a11bb4fa91 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_3@55459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-19 17:47:36 +00:00

18 lines
441 B
Ruby

# 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