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

ruby-changes:37426

From: nobu <ko1@a...>
Date: Thu, 5 Feb 2015 13:49:35 +0900 (JST)
Subject: [ruby-changes:37426] nobu:r49507 (trunk): test_inadvertent_creation.rb: assert method_missing

nobu	2015-02-05 13:49:30 +0900 (Thu, 05 Feb 2015)

  New Revision: 49507

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

  Log:
    test_inadvertent_creation.rb: assert method_missing
    
    * test/-ext-/symbol/test_inadvertent_creation.rb
      (assert_no_immortal_symbol_in_method_missing): assert
      method_missing.  [Bug #10828]

  Modified files:
    trunk/test/-ext-/symbol/test_inadvertent_creation.rb
Index: test/-ext-/symbol/test_inadvertent_creation.rb
===================================================================
--- test/-ext-/symbol/test_inadvertent_creation.rb	(revision 49506)
+++ test/-ext-/symbol/test_inadvertent_creation.rb	(revision 49507)
@@ -365,59 +365,65 @@ module Test_Symbol https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/test_inadvertent_creation.rb#L365
       assert_not_pinneddown(name)
     end
 
+    def assert_no_immortal_symbol_in_method_missing(name)
+      assert_no_immortal_symbol_created("send should not leak - #{name}") do |name|
+        assert_raise(NoMethodError) {yield(name)}
+      end
+    end
+
     def test_send_leak_string
-      assert_no_immortal_symbol_created("send should not leak - str") do |name|
-        assert_raise(NoMethodError) {42.send(name)}
+      assert_no_immortal_symbol_in_method_missing("str") do |name|
+        42.send(name)
       end
     end
 
     def test_send_leak_symbol
-      assert_no_immortal_symbol_created("send should not leak - sym") do |name|
-        assert_raise(NoMethodError) {42.send(name.to_sym)}
+      assert_no_immortal_symbol_in_method_missing("sym") do |name|
+        42.send(name.to_sym)
       end
     end
 
     def test_send_leak_string_custom_method_missing
       x = Object.new
       def x.method_missing(*); super; end
-      assert_no_immortal_symbol_created("send should not leak - str mm") do |name|
-        assert_raise(NoMethodError) {x.send(name)}
+      assert_no_immortal_symbol_in_method_missing("str mm") do |name|
+        x.send(name)
       end
     end
 
     def test_send_leak_symbol_custom_method_missing
       x = Object.new
       def x.method_missing(*); super; end
-      assert_no_immortal_symbol_created("send should not leak - sym mm") do |name|
-        assert_raise(NoMethodError) {x.send(name.to_sym)}
+      assert_no_immortal_symbol_in_method_missing("sym mm") do |name|
+        x.send(name.to_sym)
       end
     end
 
     def test_send_leak_string_no_optimization
-      assert_no_immortal_symbol_created("send should not leak - str slow") do |name|
-        assert_raise(NoMethodError) {42.method(:send).call(name)}
+      assert_no_immortal_symbol_in_method_missing("str slow") do |name|
+        42.method(:send).call(name)
       end
     end
 
     def test_send_leak_symbol_no_optimization
-      assert_no_immortal_symbol_created("send should not leak - sym slow") do |name|
-        assert_raise(NoMethodError) {42.method(:send).call(name.to_sym)}
+      assert_no_immortal_symbol_in_method_missing("sym slow") do |name|
+        42.method(:send).call(name.to_sym)
       end
     end
 
     def test_send_leak_string_custom_method_missing_no_optimization
       x = Object.new
       def x.method_missing(*); super; end
-      assert_no_immortal_symbol_created("send should not leak - str mm slow") do |name|
-        assert_raise(NoMethodError) {x.method(:send).call(name)}
+      assert_no_immortal_symbol_in_method_missing("str mm slow") do |name|
+        x.method(:send).call(name)
       end
     end
 
     def test_send_leak_symbol_custom_method_missing_no_optimization
       x = Object.new
       def x.method_missing(*); super; end
-      assert_no_immortal_symbol_created("send should not leak - sym mm slow") do |name|
-        assert_raise(NoMethodError) {x.method(:send).call(name.to_sym)}
+      assert_no_immortal_symbol_in_method_missing("sym mm slow") do |name|
+        x.method(:send).call(name.to_sym)
       end
     end
   end

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

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