зеркало из https://github.com/github/ruby.git
[ruby/prism] Fix rational when parsing non decimal integer
https://github.com/ruby/prism/commit/75d4331f7f
This commit is contained in:
Родитель
0215965df4
Коммит
3a3fcf56d0
|
@ -81,7 +81,7 @@ module Prism
|
|||
class RationalNode < Node
|
||||
# Returns the value of the node as a Ruby Rational.
|
||||
def value
|
||||
Rational(slice.chomp("r"))
|
||||
Rational(numeric.is_a?(IntegerNode) && !numeric.decimal? ? numeric.value : slice.chomp("r"))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ module Prism
|
|||
assert_equal 0.5r, parse_expression("0.5r").value
|
||||
assert_equal 42ri, parse_expression("42ri").value
|
||||
assert_equal 0.5ri, parse_expression("0.5ri").value
|
||||
assert_equal 0xFFr, parse_expression("0xFFr").value
|
||||
assert_equal 0xFFri, parse_expression("0xFFri").value
|
||||
end
|
||||
|
||||
def test_location_join
|
||||
|
|
Загрузка…
Ссылка в новой задаче