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

ruby-changes:35829

From: normal <ko1@a...>
Date: Tue, 14 Oct 2014 10:21:55 +0900 (JST)
Subject: [ruby-changes:35829] normal:r47911 (trunk): test new optimizations for redefines

normal	2014-10-14 10:21:48 +0900 (Tue, 14 Oct 2014)

  New Revision: 47911

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

  Log:
    test new optimizations for redefines
    
    * test/ruby/test_optimization.rb (test_string_freeze): new test
      (test_hash_aref_with): ditto
      (test_hash_aset_with): ditto
    
    Our new (in 2.2) optimizations must not trigger when redefined.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_optimization.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47910)
+++ ChangeLog	(revision 47911)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 14 10:19:10 2014  Eric Wong  <e@8...>
+
+	* test/ruby/test_optimization.rb (test_string_freeze): new test
+	  (test_hash_aref_with): ditto
+	  (test_hash_aset_with): ditto
+
 Tue Oct 14 01:27:54 2014  Tanaka Akira  <akr@f...>
 
 	* enum.c (nmin_run): max(n) and max_by(n) returns an array in
Index: test/ruby/test_optimization.rb
===================================================================
--- test/ruby/test_optimization.rb	(revision 47910)
+++ test/ruby/test_optimization.rb	(revision 47911)
@@ -111,6 +111,11 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L111
     assert_redefine_method('String', '%', 'assert_equal 2, "%d" % 2')
   end
 
+  def test_string_freeze
+    assert_equal "foo", "foo".freeze
+    assert_redefine_method('String', 'freeze', 'assert_nil "foo".freeze')
+  end
+
   def test_array_plus
     assert_equal [1,2], [1]+[2]
     assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')
@@ -145,6 +150,25 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L150
     assert_redefine_method('Hash', 'empty?', 'assert_nil({}.empty?); assert_nil({1=>1}.empty?)')
   end
 
+  def test_hash_aref_with
+    h = { "foo" => 1 }
+    assert_equal 1, h["foo"]
+    assert_redefine_method('Hash', '[]', <<-end)
+      h = { "foo" => 1 }
+      assert_equal "foo", h["foo"]
+    end
+  end
+
+  def test_hash_aset_with
+    h = {}
+    assert_equal 1, h["foo"] = 1
+    assert_redefine_method('Hash', '[]=', <<-end)
+      h = {}
+      h["foo"] = 1
+      assert_nil h["foo"]
+    end
+  end
+
   class MyObj
     def ==(other)
       true

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

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