summaryrefslogtreecommitdiff
path: root/test/optparse/test_placearg.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/optparse/test_placearg.rb')
-rw-r--r--test/optparse/test_placearg.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/optparse/test_placearg.rb b/test/optparse/test_placearg.rb
index 36edf401e2..d5be5a66fb 100644
--- a/test/optparse/test_placearg.rb
+++ b/test/optparse/test_placearg.rb
@@ -8,6 +8,7 @@ class TestOptionParserPlaceArg < TestOptionParser
@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
@@ -102,6 +103,11 @@ class TestOptionParserPlaceArg < TestOptionParser
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)