diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-10-02 15:20:10 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-12-04 01:35:34 +0200 |
commit | a91637c516779d9ecee5f323e211f0ed71eb06ad (patch) | |
tree | 95067387cb27a41b2bc41ca327d6379006bb2f77 /test/ruby | |
parent | f9754f0ea08e0d4fb28681a86cbc6ec2d884dba5 (diff) | |
download | ruby-a91637c516779d9ecee5f323e211f0ed71eb06ad.tar.gz |
Make {Method,UnboundMethod}#super_method handle clone/bind/unbind
This wasn't working previously because the iclass entry wasn't
being copied, and without an iclass entry, super_method returns
nil.
Fixes [Bug #15629]
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_method.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index edd1da368c..bb506f1258 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -991,6 +991,36 @@ class TestMethod < Test::Unit::TestCase assert_nil(m.super_method) end + def test_super_method_bind_unbind_clone + bug15629_m1 = Module.new do + def foo; end + end + + bug15629_m2 = Module.new do + def foo; end + end + + bug15629_c = Class.new do + include bug15629_m1 + include bug15629_m2 + end + + o = bug15629_c.new + m = o.method(:foo) + sm = m.super_method + im = bug15629_c.instance_method(:foo) + sim = im.super_method + + assert_equal(sm, m.clone.super_method) + assert_equal(sim, m.unbind.super_method) + assert_equal(sim, m.unbind.clone.super_method) + assert_equal(sim, im.clone.super_method) + assert_equal(sm, m.unbind.bind(o).super_method) + assert_equal(sm, m.unbind.clone.bind(o).super_method) + assert_equal(sm, im.bind(o).super_method) + assert_equal(sm, im.clone.bind(o).super_method) + end + def test_super_method_removed c1 = Class.new {private def foo; end} c2 = Class.new(c1) {public :foo} |