diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-03-09 07:57:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 07:57:16 -0700 |
commit | e02bd0e713ef920e6d12c27f16548f48ec5c2cf0 (patch) | |
tree | a04c6ec68aa6c9d177d09ebb5fc79bb0ece3af7e /test/ruby | |
parent | ecef163cf9bbdffcf1466addc39daa92084d6b53 (diff) | |
download | ruby-e02bd0e713ef920e6d12c27f16548f48ec5c2cf0.tar.gz |
Don't display singleton class in Method#inspect unless method defined there
Previously, if an object has a singleton class, and you call
Object#method on the object, the resulting string would include
the object's singleton class, even though the method was not
defined in the singleton class.
Change this so the we only show the singleton class if the method
is defined in the singleton class.
Fixes [Bug #15608]
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_method.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 563011a03f..01a69059e8 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -465,6 +465,14 @@ class TestMethod < Test::Unit::TestCase c3.class_eval { alias bar foo } m3 = c3.new.method(:bar) assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo)() #{__FILE__}:#{line_no}>", m3.inspect, bug7806) + + bug15608 = '[ruby-core:91570] [Bug #15608]' + c4 = Class.new(c) + c4.class_eval { alias bar foo } + o = c4.new + o.singleton_class + m4 = o.method(:bar) + assert_equal("#<Method: #{c4.inspect}(#{c.inspect})#bar(foo)() #{__FILE__}:#{line_no}>", m4.inspect, bug15608) end def test_callee_top_level |