From a1ad7b51f578dfd5f28f5c11957f03027c03e81b Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 14 Oct 2014 21:52:56 +0000 Subject: [PATCH] test/ruby/test_optimization.rb: redefinition tests for String * test/ruby/test_optimization.rb (test_string_eq_neq): new test (test_string_ltlt): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_optimization.rb | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1cec597f5c..1cf391c8dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 15 06:51:13 2014 Eric Wong + + * test/ruby/test_optimization.rb (test_string_eq_neq): new test + (test_string_ltlt): ditto + Wed Oct 15 06:50:29 2014 Eric Wong * test/ruby/test_optimization.rb (test_hash_aset_with): diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 40b1cbaa7b..2f9c0f6d22 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -116,6 +116,25 @@ class TestRubyOptimization < Test::Unit::TestCase assert_redefine_method('String', 'freeze', 'assert_nil "foo".freeze') end + def test_string_eq_neq + %w(== !=).each do |m| + assert_redefine_method('String', m, <<-end) + assert_equal :b, ("a" #{m} "b").to_sym + b = 'b' + assert_equal :b, ("a" #{m} b).to_sym + assert_equal :b, (b #{m} "b").to_sym + end + end + end + + def test_string_ltlt + assert_equal "", "" << "" + assert_equal "x", "x" << "" + assert_equal "x", "" << "x" + assert_equal "ab", "a" << "b" + assert_redefine_method('String', '<<', 'assert_equal "b", "a" << "b"') + end + def test_array_plus assert_equal [1,2], [1]+[2] assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')