diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-14 21:52:56 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-14 21:52:56 +0000 |
commit | a1ad7b51f578dfd5f28f5c11957f03027c03e81b (patch) | |
tree | 9a17fcdd075e2a4be29841f6be1365225fd4057c /test/ruby | |
parent | 5733a5745593909a4d5260264252e5465d02c964 (diff) | |
download | ruby-a1ad7b51f578dfd5f28f5c11957f03027c03e81b.tar.gz |
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
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_optimization.rb | 19 |
1 files changed, 19 insertions, 0 deletions
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]') |