summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 12:34:23 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 12:34:23 +0000
commit99bcf86ec38aee035706a0dce1990dc4b1aba31f (patch)
tree962bfc43098ffc0dc38e181f72e8bd1ca926e1f6 /test
parent7caf8a508f63d6186d42a820d1bf6b4daa661a04 (diff)
merge revision(s) 50737: [Backport #11211]
* insns.def (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/branches/ruby_2_1@52802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_defined.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb
index 6c63c7fb27..fdae6789f1 100644
--- a/test/ruby/test_defined.rb
+++ b/test/ruby/test_defined.rb
@@ -209,4 +209,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