Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ def make_switch(opts, block = nil)
block = notwice(o, block, 'block')
when Array, Hash
if Array === o
o, v = o.partition {|v| Completion.completable?(v)}
o, v = o.partition {|v,| Completion.completable?(v)}
values = notwice(v, values, 'values') unless v.empty?
next if o.empty?
end
Expand Down
6 changes: 6 additions & 0 deletions test/optparse/test_placearg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def setup
@opt.def_option("--option [VAL]") {|x| @flag = x}
@opt.def_option("-T [level]", /^[0-4]$/, Integer) {|x| @topt = x}
@opt.def_option("--enum [VAL]", [:Alpha, :Bravo, :Charlie]) {|x| @enum = x}
@opt.def_option("--enumval [VAL]", [[:Alpha, 1], [:Bravo, 2], [:Charlie, 3]]) {|x| @enum = x}
@opt.def_option("--integer [VAL]", Integer, [1, 2, 3]) {|x| @integer = x}
@opt.def_option("--range [VAL]", Integer, 1..3) {|x| @range = x}
@topt = nil
Expand Down Expand Up @@ -102,6 +103,11 @@ def test_enum
assert_equal(:Alpha, @enum)
end

def test_enum_pair
assert_equal([], no_error {@opt.parse!(%w"--enumval=A")})
assert_equal(1, @enum)
end

def test_enum_conversion
assert_equal([], no_error {@opt.parse!(%w"--integer=1")})
assert_equal(1, @integer)
Expand Down