From 4cfbf8ec95cb321e494a47fe0c82447f2ddbc872 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 29 Mar 2016 13:30:22 +0000 Subject: merge revision(s) 53695: [Backport #12030] * vm_eval.c (rb_check_funcall_with_hook): also should call the given hook before returning Qundef when overridden respond_to? method returned false. [ruby-core:73556] [Bug #12030] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_hash.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 6ee029722a..83c52a0c73 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1316,6 +1316,15 @@ class TestHash < Test::Unit::TestCase assert_equal({dug: [:foo, :bar]}, h.dig(:d, :foo, :bar)) end + def test_dig_with_respond_to + bug12030 = '[ruby-core:73556] [Bug #12030]' + o = Object.new + def o.respond_to?(*args) + super + end + assert_raise(TypeError) {{foo: o}.dig(:foo, :foo)} + end + def test_cmp h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} -- cgit v1.2.3