From a1ad7b51f578dfd5f28f5c11957f03027c03e81b Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 14 Oct 2014 21:52:56 +0000 Subject: 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 --- test/ruby/test_optimization.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby') 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]') -- cgit v1.2.3