[前][次][番号順一覧][スレッド一覧]

ruby-changes:35839

From: normal <ko1@a...>
Date: Wed, 15 Oct 2014 06:53:06 +0900 (JST)
Subject: [ruby-changes:35839] normal:r47921 (trunk): test/ruby/test_optimization.rb: redefinition tests for String

normal	2014-10-15 06:52:56 +0900 (Wed, 15 Oct 2014)

  New Revision: 47921

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47921

  Log:
    test/ruby/test_optimization.rb: redefinition tests for String
    
    * test/ruby/test_optimization.rb (test_string_eq_neq): new test
      (test_string_ltlt): ditto

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_optimization.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47920)
+++ ChangeLog	(revision 47921)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Oct 15 06:51:13 2014  Eric Wong  <e@8...>
+
+	* 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@8...>
 
 	* test/ruby/test_optimization.rb (test_hash_aset_with):
Index: test/ruby/test_optimization.rb
===================================================================
--- test/ruby/test_optimization.rb	(revision 47920)
+++ test/ruby/test_optimization.rb	(revision 47921)
@@ -116,6 +116,25 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L116
     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]')

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]