mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* proc.c (mnew): fix for instance method of Module, BasicObject
and subclass of a class which overrides respond_to_missing?. based on a patch from Nikolai Lugovoi <nlugovoi AT gmail.com> in [ruby-core:25748]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8be423f51d
commit
66a97945e3
3 changed files with 21 additions and 3 deletions
|
@ -305,8 +305,7 @@ class TestObject < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_respond_to_missing
|
||||
c = Class.new
|
||||
c.class_eval do
|
||||
c = Class.new do
|
||||
def respond_to_missing?(id)
|
||||
if id == :foobar
|
||||
true
|
||||
|
@ -335,6 +334,18 @@ class TestObject < Test::Unit::TestCase
|
|||
foobar = foo.method(:foobar)
|
||||
assert_equal([:foo], foobar.call);
|
||||
assert_equal([:foo, 1], foobar.call(1));
|
||||
|
||||
c = Class.new(c)
|
||||
assert_equal(false, c.method_defined?(:foobar))
|
||||
assert_raise(NameError, '[ruby-core:25748]') do
|
||||
c.instance_method(:foobar)
|
||||
end
|
||||
|
||||
m = Module.new
|
||||
assert_equal(false, m.method_defined?(:foobar))
|
||||
assert_raise(NameError, '[ruby-core:25748]') do
|
||||
m.instance_method(:foobar)
|
||||
end
|
||||
end
|
||||
|
||||
def test_send_with_no_arguments
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue