aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:21:11 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:21:11 +0000
commitcb3b463a50dee9d4e3d174dc9b1d7c8181678cd4 (patch)
tree0e7faca165921fba08b4e438f23049ef400dff99 /test/ruby/test_hash.rb
parent1fadd438811426523a79ccea93a45f0a202a50f6 (diff)
downloadruby-cb3b463a50dee9d4e3d174dc9b1d7c8181678cd4.tar.gz
* array.c: Improve and fix documentation for Array#dig
[#11776] * hash.c: ditto * struct.c: ditto * test_hash.rb: Add basic test for user defined `dig`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 77417ecbe0..c08908fa76 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1306,6 +1306,12 @@ class TestHash < Test::Unit::TestCase
h = @cls[a: @cls[b: [1, 2, 3]], c: 4]
assert_equal(1, h.dig(:a, :b, 0))
assert_nil(h.dig(:c, 1))
+ o = Object.new
+ def o.dig(*args)
+ {dug: args}
+ end
+ h[:d] = o
+ assert_equal({dug: [:foo, :bar]}, h.dig(:d, :foo, :bar))
end
def test_cmp