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

ruby-changes:20519

From: nobu <ko1@a...>
Date: Sun, 17 Jul 2011 12:17:27 +0900 (JST)
Subject: [ruby-changes:20519] nobu:r32567 (trunk): * test/ruby/test_module.rb (TestModule#test_method_{undefined,removed}):

nobu	2011-07-17 12:17:17 +0900 (Sun, 17 Jul 2011)

  New Revision: 32567

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

  Log:
    * test/ruby/test_module.rb (TestModule#test_method_{undefined,removed}):
      tests for method_undefined and method_removed.  Bug#5015

  Modified files:
    trunk/test/ruby/test_module.rb

Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 32566)
+++ test/ruby/test_module.rb	(revision 32567)
@@ -866,6 +866,64 @@
     assert_equal mod.instance_method(:a=), memo.shift
   end
 
+  def test_method_undefined
+    added = []
+    undefed = []
+    removed = []
+    mod = Module.new do
+      mod = self
+      def f
+      end
+      (class << self ; self ; end).class_eval do
+        define_method :method_added do |sym|
+          added << sym
+        end
+        define_method :method_undefined do |sym|
+          undefed << sym
+        end
+        define_method :method_removed do |sym|
+          removed << sym
+        end
+      end
+    end
+    assert_method_defined?(mod, :f)
+    mod.module_eval do
+      undef :f
+    end
+    assert_equal [], added
+    assert_equal [:f], undefed
+    assert_equal [], removed
+  end
+
+  def test_method_removed
+    added = []
+    undefed = []
+    removed = []
+    mod = Module.new do
+      mod = self
+      def f
+      end
+      (class << self ; self ; end).class_eval do
+        define_method :method_added do |sym|
+          added << sym
+        end
+        define_method :method_undefined do |sym|
+          undefed << sym
+        end
+        define_method :method_removed do |sym|
+          removed << sym
+        end
+      end
+    end
+    assert_method_defined?(mod, :f)
+    mod.module_eval do
+      remove_method :f
+    end
+    assert_equal [], added
+    assert_equal [], undefed
+    assert_equal [:f], removed
+  end
+
   def test_method_redefinition
     feature2155 = '[ruby-dev:39400]'
 

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

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