summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-17 09:25:11 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-17 09:25:11 +0000
commitfbf633c3723368470cf7adf79e703b06c3ed4a0c (patch)
treec52f01d87e7f31f809bf6d8a87e2cb7b009822f2 /test
parent2a13a71e80e2be2dbc84ba3d9eeb0b3100345869 (diff)
merge revision(s) 63067,63068: [Backport #14658]
Fix Kernel#singleton_method with Module#Prepend * proc.c (rb_obj_singleton_method): search the method entry from the origin class, for fix prepended modules. [Bug #14658] From: Vasiliy Ermolovich <younash@gmail.com> proc.c: fix segfault when no singleton class * proc.c (rb_obj_singleton_method): bail out if the receiver does not have the singleton class without accessing the origin class not to segfault. [Bug #14658] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@65118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_method.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 128999a4c9..189f24b194 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -779,6 +779,19 @@ class TestMethod < Test::Unit::TestCase
assert_equal(:bar, m.call, feature8391)
end
+ def test_singleton_method_prepend
+ bug14658 = '[Bug #14658]'
+ c1 = Class.new
+ o = c1.new
+ def o.bar; :bar; end
+ class << o; prepend Module.new; end
+ m = assert_nothing_raised(NameError, bug14658) {o.singleton_method(:bar)}
+ assert_equal(:bar, m.call, bug14658)
+
+ o = Object.new
+ assert_raise(NameError, bug14658) {o.singleton_method(:bar)}
+ end
+
Feature9783 = '[ruby-core:62212] [Feature #9783]'
def assert_curry_three_args(m)