diff options
| author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-22 14:33:11 +0000 |
|---|---|---|
| committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-22 14:33:11 +0000 |
| commit | f0f3821be7507a96e613e6d8e7e675eada78a892 (patch) | |
| tree | e4a52931045ae0d6a5f6252837eb6fa0054fc1cb /test/ruby/test_method.rb | |
| parent | 86d9d122bef745aad9bf3dabd80ad03fbec1beec (diff) | |
merge revision(s) 44175,44179: [Backport #9236]
* proc.c (method_owner): return the class where alias is defined, not
the class original method is defined.
* vm_method.c (rb_method_entry_make, rb_alias): store the originally
defined class in me. [Bug #7993] [Bug #7842] [Bug #9236]
* vm_method.c (rb_method_entry_get_without_cache): cache included
module but not iclass.
* proc.c (mnew_from_me): achieve the original defined_class from
prepended iclass, to fix inherited owner.
* proc.c (method_owner): return the defined class, but not the
class which the method object is created from.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_method.rb')
| -rw-r--r-- | test/ruby/test_method.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 6d0f6acf35..1514c26f5c 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -180,6 +180,15 @@ class TestMethod < Test::Unit::TestCase assert_equal(Array.instance_method(:map).hash, Array.instance_method(:collect).hash) end + def test_owner + c = Class.new do + def foo; end + end + assert_equal(c, c.instance_method(:foo).owner) + c2 = Class.new(c) + assert_equal(c, c2.instance_method(:foo).owner) + end + def test_receiver_name_owner o = Object.new def o.foo; end @@ -534,17 +543,23 @@ class TestMethod < Test::Unit::TestCase def test_alias_owner bug7613 = '[ruby-core:51105]' + bug7993 = '[Bug #7993]' c = Class.new { def foo end + prepend Module.new + attr_reader :zot } x = c.new class << x alias bar foo end + assert_equal(c, c.instance_method(:foo).owner) assert_equal(c, x.method(:foo).owner) assert_equal(x.singleton_class, x.method(:bar).owner) assert(x.method(:foo) != x.method(:bar), bug7613) + assert_equal(c, x.method(:zot).owner, bug7993) + assert_equal(c, c.instance_method(:zot).owner, bug7993) end def test_gced_bmethod |
