From 8ddf0263bb0a8536e40eb088d8620f13f28c4c52 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 6 Jul 2017 11:49:03 +0000 Subject: Fix DecimalInteger converting to octal bug Previously if the input started with a '0' then it will be converted as octal even though it has been specified as a decimal. This commit forces the number to be interpreted as a decimal. [ruby-core:81927] [Bug #13722] [Fix GH-1665] Author: william git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/optparse/test_acceptable.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/optparse') diff --git a/test/optparse/test_acceptable.rb b/test/optparse/test_acceptable.rb index 0c7590bae3..dd38f8ec7a 100644 --- a/test/optparse/test_acceptable.rb +++ b/test/optparse/test_acceptable.rb @@ -108,16 +108,16 @@ class TestOptionParser::Acceptable < TestOptionParser assert_equal(%w"", no_error {@opt.parse!(%w"--decimal-integer 10")}) assert_equal(10, @decimal_integer) + assert_equal(%w"", no_error {@opt.parse!(%w"--decimal-integer 010")}) + assert_equal(10, @decimal_integer) + + assert_equal(%w"", no_error {@opt.parse!(%w"--decimal-integer 09")}) + assert_equal(9, @decimal_integer) + assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer 0b1") end - e = assert_raise(OptionParser::InvalidArgument) do - @opt.parse!(%w"--decimal-integer 09") - end - - assert_equal("invalid argument: --decimal-integer 09", e.message) - assert_raise(OptionParser::InvalidArgument) do @opt.parse!(%w"--decimal-integer x") end -- cgit v1.2.3