diff options
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_optimization.rb | 24 |
1 files changed, 24 insertions, 0 deletions
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 |