Issue #11804 has been updated by Usaku NAKAMURA.

Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE

ruby_2_1 r53147 merged revision(s) 53039.

----------------------------------------
Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生する
https://bugs.ruby-lang.org/issues/11804#change-55588

* Author: Kaneko Yuichiro
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-12-11 trunk 53027) [x86_64-darwin14]
* Backport: 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE
----------------------------------------
以下のようなケースです。

```ruby
  def test_infinity
    inf = 1.0/0.0

    result = case inf
             when true then 1
             when false then 0
             else
               inf.to_i rescue nil
             end

    assert_nil result
  end
```

52930の場合

```
# Running tests:

Finished tests in 0.136572s, 51.2550 tests/s, 314.8522 assertions/s.
7 tests, 43 assertions, 0 failures, 0 errors, 0 skips
```

52931の場合

```
[4/7] TestCase#test_infinity = 0.00 s
  1) Error:
TestCase#test_infinity:
FloatDomainError: Infinity
    ruby/test/ruby/test_case.rb:156:in `test_infinity'

Finished tests in 0.135196s, 51.7767 tests/s, 310.6601 assertions/s.
7 tests, 42 assertions, 0 failures, 1 errors, 0 skips
```

なお`when`のあとがStringのみのケースだと2.2.3でも例外が発生します。

```ruby
irb(main):001:0> RUBY_VERSION
=> "2.2.3"
irb(main):002:0>     inf = 1.0/0.0
=> Infinity
irb(main):003:0>
irb(main):004:0*     result = case inf
irb(main):005:1>              when 'str' then :string
irb(main):006:1>              else
irb(main):007:1*                inf.to_i rescue nil
irb(main):008:1>              end
FloatDomainError: Infinity
	from (irb):4
	from .rbenv/versions/2.2.3/bin/irb:11:in `<main>'
```




-- 
https://bugs.ruby-lang.org/