summaryrefslogtreecommitdiff
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-31 05:23:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-31 05:23:01 +0000
commit160d02d830d93316a8b4afd54138c1a8bfb8a6b3 (patch)
tree10f355909c45a2d9bf76f3918964533519ce9fc7 /test/ruby/test_hash.rb
parent15ca66efb0292388e2c8b6772bf0549a7c396eb9 (diff)
* hash.c (hash_default_value): extract from rb_hash_aref(), to be
shared with rb_hash_shift(), so that overriding Hash#default will be respected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 494fc98a9f..4b635a194d 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -739,6 +739,14 @@ class TestHash < Test::Unit::TestCase
h.each { assert_equal([1, 2], h.shift) }
end
+ def test_shift_none
+ h = Hash.new {|hh, k| "foo"}
+ def h.default(k = nil)
+ default_proc.call(k).upcase
+ end
+ assert_equal("FOO", h.shift)
+ end
+
def test_reject_bang2
assert_equal({1=>2}, {1=>2,3=>4}.reject! {|k, v| k + v == 7 })
assert_nil({1=>2,3=>4}.reject! {|k, v| k == 5 })