summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-09 13:40:14 +0000
committerwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-09 13:40:14 +0000
commit96688ecbab2e18be02af7172bcb3732e57d9290e (patch)
treea4f5761850518bd0a89e98d4e0fb681906f8cff9 /test
parente54c30c05eb16897bc1d44b3bec06083ef1ae779 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_case.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb
index 98498dada6..0067b74e2b 100644
--- a/test/ruby/test_case.rb
+++ b/test/ruby/test_case.rb
@@ -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