mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_insnhelper.c (vm_defined): check respond_to_missing?
at defined?(func()). * test/ruby/test_defined.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5bcae57c6f
commit
a54da1c050
3 changed files with 42 additions and 7 deletions
|
@ -223,6 +223,14 @@ class TestDefined < Test::Unit::TestCase
|
|||
|
||||
def existing_method
|
||||
end
|
||||
|
||||
def func_defined_existing_func
|
||||
defined?(existing_method())
|
||||
end
|
||||
|
||||
def func_defined_non_existing_func
|
||||
defined?(non_existing_method())
|
||||
end
|
||||
end
|
||||
|
||||
def test_method_by_respond_to_missing
|
||||
|
@ -232,5 +240,12 @@ class TestDefined < Test::Unit::TestCase
|
|||
assert_equal(false, obj.called, bug_11211)
|
||||
assert_equal(nil, defined?(obj.non_existing_method), bug_11211)
|
||||
assert_equal(true, obj.called, bug_11211)
|
||||
|
||||
bug_11212 = '[Bug #11212]'
|
||||
obj = ExampleRespondToMissing.new
|
||||
assert_equal("method", obj.func_defined_existing_func, bug_11212)
|
||||
assert_equal(false, obj.called, bug_11212)
|
||||
assert_equal(nil, obj.func_defined_non_existing_func, bug_11212)
|
||||
assert_equal(true, obj.called, bug_11212)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue