vm_method.c: fix method_removed

* vm_method.c: call method_removed hook on called class, not on
  prepending iclass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-02-14 01:30:47 +00:00
parent 8c5a6fb684
commit 01e43fb0e2
3 changed files with 24 additions and 3 deletions

View file

@ -1382,12 +1382,27 @@ class TestModule < Test::Unit::TestCase
end
def test_prepend_remove_method
c = Class.new do
prepend Module.new {def foo; end}
end
assert_raise(NameError) do
Class.new do
prepend Module.new {def foo; end}
c.class_eval do
remove_method(:foo)
end
end
c.class_eval do
def foo; end
end
removed = nil
c.singleton_class.class_eval do
define_method(:method_removed) {|id| removed = id}
end
assert_nothing_raised(NoMethodError, NameError) do
c.class_eval do
remove_method(:foo)
end
end
assert_equal(:foo, removed)
end
def test_prepend_class_ancestors