mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/-ext-/hash/test_delete.rb: assert deleted values
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ca7835bec6
commit
d4c22161f3
2 changed files with 4 additions and 4 deletions
|
@ -4,11 +4,11 @@ static VALUE
|
|||
hash_delete(VALUE hash, VALUE key)
|
||||
{
|
||||
VALUE ret = rb_hash_delete(hash, key);
|
||||
return ret == Qundef ? Qfalse : Qtrue;
|
||||
return ret == Qundef ? Qnil : rb_ary_new_from_values(1, &ret);
|
||||
}
|
||||
|
||||
void
|
||||
Init_delete(VALUE klass)
|
||||
{
|
||||
rb_define_method(klass, "delete", hash_delete, 1);
|
||||
rb_define_method(klass, "delete!", hash_delete, 1);
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ class TestHash < Test::Unit::TestCase
|
|||
hash[1] = 2
|
||||
called = false
|
||||
assert_equal 1, hash.size
|
||||
assert_equal true, hash.delete(1) {called = true}
|
||||
assert_equal [2], hash.delete!(1) {called = true}
|
||||
assert_equal false, called, "block called"
|
||||
assert_equal 0, hash.size
|
||||
assert_equal false, hash.delete(1) {called = true}
|
||||
assert_equal nil, hash.delete!(1) {called = true}
|
||||
assert_equal false, called, "block called"
|
||||
assert_equal 0, hash.size
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue