mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (case_when_optimizable_literal): When float value can be
treated as integer, add to table hash of case that way. based on a patch from Ikuo KOBORI. [ruby-dev:42038] * insnf.def (opt_case_dispatch): ditto. * test/ruby/test_case.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e54c30c05e
commit
96688ecbab
4 changed files with 55 additions and 8 deletions
|
@ -84,4 +84,23 @@ class TestCase < Test::Unit::TestCase
|
|||
class Fixnum; undef ===; def ===(o); p 42; true; end; end; case 1; when 1; end
|
||||
EOS
|
||||
end
|
||||
|
||||
def test_optimization
|
||||
case 1
|
||||
when 0.9, 1.1
|
||||
assert(false)
|
||||
when 1.0
|
||||
assert(true)
|
||||
else
|
||||
assert(false)
|
||||
end
|
||||
case 536870912
|
||||
when 536870911.9, 536870912.1
|
||||
assert(false)
|
||||
when 536870912.0
|
||||
assert(true)
|
||||
else
|
||||
assert(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue