aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_object.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 03:18:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 03:18:25 +0000
commit55148a250101b662fde32919f14afcf2dcdc801d (patch)
treefc5c632f160f695dabc3579a58b4fb188fd7e190 /test/ruby/test_object.rb
parent2205687ccf6caf2d7b9998478751508afba707c6 (diff)
downloadruby-55148a250101b662fde32919f14afcf2dcdc801d.tar.gz
* vm_eval.c (check_funcall): try respond_to? first if redefined.
[Bug #5158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_object.rb')
-rw-r--r--test/ruby/test_object.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index c4f0f79db3..b23a8e6498 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -396,6 +396,31 @@ class TestObject < Test::Unit::TestCase
end
end
+ def test_implicit_respond_to
+ bug5158 = '[ruby-core:38799]'
+
+ p = Object.new
+
+ called = []
+ p.singleton_class.class_eval do
+ define_method(:to_ary) do
+ called << [:to_ary, bug5158]
+ end
+ end
+ [[p]].flatten
+ assert_equal([[:to_ary, bug5158]], called, bug5158)
+
+ called = []
+ p.singleton_class.class_eval do
+ define_method(:respond_to?) do |*a|
+ called << [:respond_to?, *a]
+ false
+ end
+ end
+ [[p]].flatten
+ assert_equal([[:respond_to?, :to_ary, true]], called, bug5158)
+ end
+
def test_send_with_no_arguments
assert_raise(ArgumentError) { 1.send }
end