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

ruby-changes:59833

From: Koichi <ko1@a...>
Date: Tue, 28 Jan 2020 15:24:39 +0900 (JST)
Subject: [ruby-changes:59833] cc2fe6936c (master): support multi-run for test/ruby/test_method.rb

https://git.ruby-lang.org/ruby.git/commit/?id=cc2fe6936c

From cc2fe6936c0e9b815d43a942d2bb7dff0363ccf6 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Tue, 28 Jan 2020 13:58:01 +0900
Subject: support multi-run for test/ruby/test_method.rb

need to restore a method.

diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 7577a53..dd163e1 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -104,6 +104,12 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L104
     assert_raise(TypeError) do
       um.bind(Base.new)
     end
+
+    # cleanup
+    Derived.class_eval do
+      remove_method :foo
+      def foo() :derived; end
+    end
   end
 
   def test_callee
@@ -1102,17 +1108,26 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L1108
     assert_equal([:bar, :foo], b.local_variables.sort, bug11012)
   end
 
-  class MethodInMethodClass
-    def m1
-      def m2
-      end
+  setup_for_test_method_in_method_visibility_should_be_public_proc = -> do
+    remove_const :MethodInMethodClass if defined? MethodInMethodClass
 
-      self.class.send(:define_method, :m3){} # [Bug #11754]
+    class MethodInMethodClass
+      def m1
+        def m2
+        end
+        self.class.send(:define_method, :m3){} # [Bug #11754]
+      end
+      private
     end
-    private
+  end
+
+  define_method :setup_for_test_method_in_method_visibility_should_be_public do
+    setup_for_test_method_in_method_visibility_should_be_public_proc.call
   end
 
   def test_method_in_method_visibility_should_be_public
+    setup_for_test_method_in_method_visibility_should_be_public
+
     assert_equal([:m1].sort, MethodInMethodClass.public_instance_methods(false).sort)
     assert_equal([].sort, MethodInMethodClass.private_instance_methods(false).sort)
 
-- 
cgit v0.10.2


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

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