mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/psych] Fix ArgumentError with leading and trailing underscores in number strings.
https://github.com/ruby/psych/commit/ac2d2c9b1b
This commit is contained in:
parent
5ed58b90d1
commit
f245976386
Notes:
git
2020-06-05 11:50:25 +09:00
2 changed files with 4 additions and 1 deletions
|
@ -101,7 +101,7 @@ module Psych
|
|||
###
|
||||
# Parse and return an int from +string+
|
||||
def parse_int string
|
||||
Integer(string.gsub(/[,]/, ''))
|
||||
Integer(string.gsub(/[,_]/, ''))
|
||||
end
|
||||
|
||||
###
|
||||
|
|
|
@ -120,6 +120,7 @@ module Psych
|
|||
assert_equal 123_456_789, ss.tokenize('123_456_789')
|
||||
assert_equal 123_456_789, ss.tokenize('123,456,789')
|
||||
assert_equal 123_456_789, ss.tokenize('1_2,3,4_5,6_789')
|
||||
assert_equal 123_456_789, ss.tokenize('1_2,3,4_5,6_789_')
|
||||
|
||||
assert_equal 0b010101010, ss.tokenize('0b010101010')
|
||||
assert_equal 0b010101010, ss.tokenize('0b0,1_0,1_,0,1_01,0')
|
||||
|
@ -129,6 +130,8 @@ module Psych
|
|||
|
||||
assert_equal 0x123456789abcdef, ss.tokenize('0x123456789abcdef')
|
||||
assert_equal 0x123456789abcdef, ss.tokenize('0x12_,34,_56,_789abcdef')
|
||||
assert_equal 0x123456789abcdef, ss.tokenize('0x_12_,34,_56,_789abcdef')
|
||||
assert_equal 0x123456789abcdef, ss.tokenize('0x12_,34,_56,_789abcdef__')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue