summaryrefslogtreecommitdiff
path: root/test/option_test.rb
diff options
context:
space:
mode:
authorLee Jarvis <lee@jarvis.co>2011-05-17 12:35:06 +0100
committerLee Jarvis <lee@jarvis.co>2011-05-17 12:35:06 +0100
commit56dd782aa3d01b50c0d6f3233705c6fdb7db288f (patch)
treeba65ff6c4c5e2b922a080f71520ce3caf9eb231f /test/option_test.rb
parent90f8fd17b3187d173f0c12f43a1185b2b349a205 (diff)
downloadslop-56dd782aa3d01b50c0d6f3233705c6fdb7db288f.tar.gz
do not parse negative integers as options
a valid option must begin with an alphabet character
Diffstat (limited to 'test/option_test.rb')
-rw-r--r--test/option_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/option_test.rb b/test/option_test.rb
index 3f5aebe..3b93e42 100644
--- a/test/option_test.rb
+++ b/test/option_test.rb
@@ -70,6 +70,11 @@ class OptionTest < TestCase
assert_equal :foo, option_value(%w/--name foo/, :name, true, :as => :sym)
assert_equal 30, option_value(%w/--age 30/, :age, true, :as => Integer)
assert_equal "1.0", option_value(%w/--id 1/, :id, true, :as => Float).to_s
+
+ assert_equal -1, option_value(%w/-i -1/, :i, true, :as => Integer)
+ assert_equal -1, option_value(%w/-i -1.1/, :i, true, :as => Integer)
+ assert_equal "-1.1", option_value(%w/-i -1.1/, :i, true, :as => Float).to_s
+ assert_equal "foo", option_value(%w/--foo1 foo/, :foo1, true)
end
test 'ranges' do