diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-08 17:10:43 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-08 17:10:43 +0000 |
commit | 4beed07cf7ec7a2cdff73c9a0675b40a340fa186 (patch) | |
tree | 29ef104afee1469d1804e1128fac1c08beb81271 | |
parent | 3bec9a875387e0ad7737115d4cd708cdc3e6e7d5 (diff) | |
download | ruby-4beed07cf7ec7a2cdff73c9a0675b40a340fa186.tar.gz |
merge revision(s) 52928: [Backport #11784]
* insns.def (opt_case_dispatch): check Float#=== redefinition
* test/ruby/test_optimization.rb (test_opt_case_dispatch): new
[ruby-core:71920] [Bug #11784]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@52977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | insns.def | 1 | ||||
-rw-r--r-- | test/ruby/test_optimization.rb | 41 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 49 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Wed Dec 9 01:49:13 2015 Eric Wong <e@80x24.org> + + * insns.def (opt_case_dispatch): check Float#=== redefinition + * test/ruby/test_optimization.rb (test_opt_case_dispatch): new + [ruby-core:71920] [Bug #11784] + Wed Dec 9 01:46:23 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * ruby_atomic.h (ATOMIC_SIZE_CAS): fix the argument order of @@ -1326,6 +1326,7 @@ opt_case_dispatch if (BASIC_OP_UNREDEFINED_P(BOP_EQQ, SYMBOL_REDEFINED_OP_FLAG | FIXNUM_REDEFINED_OP_FLAG | + FLOAT_REDEFINED_OP_FLAG | BIGNUM_REDEFINED_OP_FLAG | STRING_REDEFINED_OP_FLAG)) { st_data_t val; diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 4a5484e43d..9250f013c4 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -289,4 +289,45 @@ class TestRubyOptimization < Test::Unit::TestCase assert_equal(false, "block".freeze) end; end + + def test_opt_case_dispatch + code = <<-EOF + case foo + when "foo" then :foo + when :sym then :sym + when 6 then :fix + when 0.1 then :float + when 0xffffffffffffffff then :big + else + :nomatch + end + EOF + check = { + 'foo' => :foo, + :sym => :sym, + 6 => :fix, + 0.1 => :float, + 0xffffffffffffffff => :big, + } + iseq = RubyVM::InstructionSequence.compile(code) + assert_match %r{\bopt_case_dispatch\b}, iseq.disasm + check.each do |foo, expect| + assert_equal expect, eval("foo = #{foo.inspect}\n#{code}") + end + assert_equal :nomatch, eval("foo = :blah\n#{code}") + check.each do |foo, _| + klass = foo.class.to_s + assert_separately([], <<-"end;") # do + class #{klass} + undef === + def ===(*args) + false + end + end + foo = #{foo.inspect} + ret = #{code} + assert_equal :nomatch, ret, foo.inspect + end; + end + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.4" #define RUBY_RELEASE_DATE "2015-12-09" -#define RUBY_PATCHLEVEL 223 +#define RUBY_PATCHLEVEL 224 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 12 |