aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-14 01:21:48 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-14 01:21:48 +0000
commit18828191d4e88242d791ec65dee5b1912332de7a (patch)
treeae35592b476e6f094f88725b501f1f4b63fe6177
parent2f83b32f7123508239da5ed670a45e831d614ac7 (diff)
downloadruby-18828191d4e88242d791ec65dee5b1912332de7a.tar.gz
test new optimizations for redefines
* test/ruby/test_optimization.rb (test_string_freeze): new test (test_hash_aref_with): ditto (test_hash_aset_with): ditto Our new (in 2.2) optimizations must not trigger when redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_optimization.rb24
2 files changed, 30 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index aa563bae81..c9f9ec5588 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Oct 14 10:19:10 2014 Eric Wong <e@80x24.org>
+
+ * test/ruby/test_optimization.rb (test_string_freeze): new test
+ (test_hash_aref_with): ditto
+ (test_hash_aset_with): ditto
+
Tue Oct 14 01:27:54 2014 Tanaka Akira <akr@fsij.org>
* enum.c (nmin_run): max(n) and max_by(n) returns an array in
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index 7bd2c1804a..f991beaaa5 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -111,6 +111,11 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_redefine_method('String', '%', 'assert_equal 2, "%d" % 2')
end
+ def test_string_freeze
+ assert_equal "foo", "foo".freeze
+ assert_redefine_method('String', 'freeze', 'assert_nil "foo".freeze')
+ end
+
def test_array_plus
assert_equal [1,2], [1]+[2]
assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')
@@ -145,6 +150,25 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_redefine_method('Hash', 'empty?', 'assert_nil({}.empty?); assert_nil({1=>1}.empty?)')
end
+ def test_hash_aref_with
+ h = { "foo" => 1 }
+ assert_equal 1, h["foo"]
+ assert_redefine_method('Hash', '[]', <<-end)
+ h = { "foo" => 1 }
+ assert_equal "foo", h["foo"]
+ end
+ end
+
+ def test_hash_aset_with
+ h = {}
+ assert_equal 1, h["foo"] = 1
+ assert_redefine_method('Hash', '[]=', <<-end)
+ h = {}
+ h["foo"] = 1
+ assert_nil h["foo"]
+ end
+ end
+
class MyObj
def ==(other)
true