diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-17 03:17:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-17 03:17:17 +0000 |
commit | 1297cc615c5ddbe70451e94568798dbd40dbd414 (patch) | |
tree | 0ab6edf4f0c091ad817fc040698525c51d213c59 /test/ruby/test_module.rb | |
parent | 6349c7bf4dcbd33e92f8b187d83b8fad22cd8fb0 (diff) | |
download | ruby-1297cc615c5ddbe70451e94568798dbd40dbd414.tar.gz |
* test/ruby/test_module.rb (TestModule#test_method_{undefined,removed}):
tests for method_undefined and method_removed. Bug#5015
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r-- | test/ruby/test_module.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e2649a908f..e6c107961d 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -866,6 +866,64 @@ class TestModule < Test::Unit::TestCase 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]' |