mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
insns.def (opt_case_dispatch): avoid converting Infinity
Infinity cannot be written as an optimizable literal, so it can never match a key in a CDHASH. Avoid converting it to prevent FloatDomainError. * insns.def (opt_case_dispatch): avoid converting Infinity * test/ruby/test_optimization.rb (test_opt_case_dispatch_inf): new [ruby-dev:49423] [Bug #11804] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89288e30bf
commit
d65bc80d3f
3 changed files with 18 additions and 1 deletions
|
@ -362,4 +362,15 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
assert_redefine_method(k, '===', "assert_equal(#{v.inspect} === 0, 0)")
|
||||
end
|
||||
end
|
||||
|
||||
def test_opt_case_dispatch_inf
|
||||
inf = 1.0/0.0
|
||||
result = case inf
|
||||
when 1 then 1
|
||||
when 0 then 0
|
||||
else
|
||||
inf.to_i rescue nil
|
||||
end
|
||||
assert_nil result, '[ruby-dev:49423] [Bug #11804]'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue