aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-30 06:19:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-30 06:19:13 +0000
commit5eb54ecce618a721ebb88c7b506da861adc3d5b4 (patch)
tree9005e49d5bffd7bdc23171af544bb8b319e72434 /test/ruby/test_hash.rb
parentbba14c4a23bc1ab9810cf9c4fd1eeb657afc8bd2 (diff)
downloadruby-5eb54ecce618a721ebb88c7b506da861adc3d5b4.tar.gz
vm_eval.c: fix hook call
* 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/trunk@53695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 3baba6a0b7..8b6910cf3b 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1324,6 +1324,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}