diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-02 19:36:43 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-02 19:36:43 +0000 |
commit | 12bba62a82d246d9416aed17e40f57b6c1dd7d16 (patch) | |
tree | 83d51d22d9283ab3f632c9e0cfc3bf954f359487 /test/ruby/test_defined.rb | |
parent | 91c5320fbbf00aca480a130d46fbc8ca8193e062 (diff) | |
download | ruby-12bba62a82d246d9416aed17e40f57b6c1dd7d16.tar.gz |
* vm_insnhelper.c (vm_defined): skip respond_to_missing? when
a method is available.
[Bug #11211]
* test/ruby/test_defined.rb: add a test for this fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_defined.rb')
-rw-r--r-- | test/ruby/test_defined.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index d5e84185cc..64757615ec 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -208,4 +208,29 @@ class TestDefined < Test::Unit::TestCase def test_super_toplevel assert_separately([], "assert_nil(defined?(super))") end + + class ExampleRespondToMissing + attr_reader :called + + def initialize + @called = false + end + + def respond_to_missing? *args + @called = true + false + end + + def existing_method + end + end + + def test_method_by_respond_to_missing + bug_11211 = '[Bug #11211]' + obj = ExampleRespondToMissing.new + assert_equal("method", defined?(obj.existing_method), bug_11211) + assert_equal(false, obj.called, bug_11211) + assert_equal(nil, defined?(obj.non_existing_method), bug_11211) + assert_equal(true, obj.called, bug_11211) + end end |