diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2021-05-07 10:04:08 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2021-05-12 10:30:46 +0900 |
commit | 2bc293e899c9d32dcd794a73de8925c49ecf8f15 (patch) | |
tree | 7579535ee779a40dcbb27df91193768bd92f771a /test/ruby/test_rational.rb | |
parent | 773c690f2553db31a9cc83a037f5449e0c1ea456 (diff) |
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]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4469
Diffstat (limited to 'test/ruby/test_rational.rb')
-rw-r--r-- | test/ruby/test_rational.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index fe9de64c4c..d7f4961214 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -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) |