mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 04:24:04 +02:00
cdhash_cmp: can take rational literals
Rational literals are those integers suffixed with `r`. They tend to be a part of more complex expressions like `123/456r`, but in theory they can live alone. When such "bare" rational literals are passed to case-when branch, we have to take care of them. Fixes [Bug #17854]
This commit is contained in:
parent
773c690f25
commit
2bc293e899
Notes:
git
2021-05-12 10:31:14 +09:00
5 changed files with 26 additions and 3 deletions
|
@ -830,6 +830,13 @@ class Rational_Test < Test::Unit::TestCase
|
|||
assert_raise(ZeroDivisionError) {Rational("1/0")}
|
||||
end
|
||||
|
||||
def test_cdhash
|
||||
assert_separately([], <<-RUBY)
|
||||
n = case 1 when 2r then false else true end
|
||||
assert_equal(n, true, '[ruby-core:103759] [Bug #17854]')
|
||||
RUBY
|
||||
end
|
||||
|
||||
def test_Rational_with_invalid_exception
|
||||
assert_raise(ArgumentError) {
|
||||
Rational("1/1", exception: 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue