diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-01 15:39:58 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-01 15:39:58 +0000 |
commit | a9b1e5c27b93a6926bacf8139da136153e2dc1a9 (patch) | |
tree | 72b98d6e3c666a84a616a5ba0118918dc18bd59b /test | |
parent | 536770bfb01d126c1db63bb444188c8235794b58 (diff) |
Added a test method contributed by James M Lawrence,
and merged a modification from r24868.
* test/ruby/test_module.rb (TestModule#test_method_added): new test
method. Patch by James M. Lawrence.
c.f. [ruby-core:25536], r24867 and r24868.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_module.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index ff74fc7f73..1540e98686 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -728,4 +728,34 @@ class TestModule < Test::Unit::TestCase c = eval("class C\u{df}; self; end") assert_equal("TestModule::C\u{df}", c.name, '[ruby-core:24600]') end + + def test_method_added + memo = [] + mod = Module.new do + (class << self ; self ; end).class_eval do + define_method :method_added do |sym| + memo << sym + memo << instance_methods(false) + memo << (instance_method(sym) rescue nil) + end + end + def f + end + alias g f + attr_reader :a + attr_writer :a + end + assert_equal :f, memo.shift + assert_equal [:f], memo.shift, '[ruby-core:25536]' + assert_equal mod.instance_method(:f), memo.shift + assert_equal :g, memo.shift + assert_equal [:f, :g], memo.shift + assert_equal mod.instance_method(:f), memo.shift + assert_equal :a, memo.shift + assert_equal [:f, :g, :a], memo.shift + assert_equal mod.instance_method(:a), memo.shift + assert_equal :a=, memo.shift + assert_equal [:f, :g, :a, :a=], memo.shift + assert_equal mod.instance_method(:a=), memo.shift + end end |