diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_optimization.rb | 19 |
2 files changed, 24 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Wed Oct 15 06:51:13 2014 Eric Wong <e@80x24.org> + + * test/ruby/test_optimization.rb (test_string_eq_neq): new test + (test_string_ltlt): ditto + Wed Oct 15 06:50:29 2014 Eric Wong <e@80x24.org> * 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]') |