summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2019-06-24 19:01:13 +0900
committerSutou Kouhei <kou@clear-code.com>2019-06-29 06:18:09 +0900
commitc026ee99247c33130addc01d1399e71b14879f38 (patch)
treeb50c90fbcefadd3d2e3b73792eba68ac37bd9617 /test
parentaa233ababf00cd32f46a278ca030d5c40281e7c1 (diff)
downloadslop-c026ee99247c33130addc01d1399e71b14879f38.tar.gz
Fix a bug that flag value is processed as flag
If flag value starts with "-", unknown option error is raised. The current flag value check is "orig_arg == opt.value.to_s". There are some objects such as Regexp and Time that input value and its #to_s aren't same.
Diffstat (limited to 'test')
-rw-r--r--test/parser_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/parser_test.rb b/test/parser_test.rb
index caee0dd..ef09714 100644
--- a/test/parser_test.rb
+++ b/test/parser_test.rb
@@ -35,6 +35,12 @@ describe Slop::Parser do
assert_equal "--sometext", @result[:text]
end
+ it "parses regexp arg with leading -" do
+ @options.regexp "--pattern"
+ @result.parser.parse %w(--pattern -x)
+ assert_equal(/-x/, @result[:pattern])
+ end
+
it "parses negative integer" do
@options.integer "-p", "--port"
@result.parser.parse %w(--name=bob --port -123)