aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-03-09 07:57:16 -0700
committerNARUSE, Yui <naruse@airemix.jp>2020-03-14 16:15:15 +0900
commit0d24fb774d84d4a99454ce10fd343da00049a588 (patch)
treef1ec98c8cc5a5d7113093f02a78c2fcd90b5d312 /test
parenteabf35a5d298c68f45dc600477fc586d7b868788 (diff)
downloadruby-0d24fb774d84d4a99454ce10fd343da00049a588.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] (cherry picked from commit e02bd0e713ef920e6d12c27f16548f48ec5c2cf0)
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_method.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index bb506f1258..6ad9620a00 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -459,6 +459,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