summaryrefslogtreecommitdiff
path: root/test/optparse
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-03-29 16:42:49 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-03-29 19:37:24 +0900
commite8317d90b0b102ba270b456cc6cb7c6865c6b448 (patch)
tree0889564769d0de1db072887223ce2e386c6d8ca6 /test/optparse
parent2bbae0e91acf1090bbcea49476ef007162ec8e2b (diff)
[ruby/optparse] Fixed error message of unparsed non-option
Close https://github.com/ruby/optparse/issues/3 https://github.com/ruby/optparse/commit/94c5cf4032
Diffstat (limited to 'test/optparse')
-rw-r--r--test/optparse/test_optparse.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb
index fec14fc..5f5ea18 100644
--- a/test/optparse/test_optparse.rb
+++ b/test/optparse/test_optparse.rb
@@ -97,4 +97,12 @@ class TestOptionParser < Test::Unit::TestCase
assert_raise(OptionParser::InvalidOption) {@opt.parse(%w(-zr foo))}
assert_raise(OptionParser::InvalidOption) {@opt.parse(%w(-z foo))}
end
+
+ def test_nonopt_pattern
+ @opt.def_option(/^[^-]/) do |arg|
+ assert(false, "Never gets called")
+ end
+ e = assert_raise(OptionParser::InvalidOption) {@opt.parse(%w(-t))}
+ assert_equal(["-t"], e.args)
+ end
end