2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2014-10-23 08:42:57 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require '-test-/hash'
|
|
|
|
|
|
|
|
class TestHash < Test::Unit::TestCase
|
|
|
|
class TestDelete < Test::Unit::TestCase
|
|
|
|
def test_delete
|
|
|
|
hash = Bug::Hash.new
|
|
|
|
hash[1] = 2
|
|
|
|
called = false
|
|
|
|
assert_equal 1, hash.size
|
2014-10-23 10:18:32 -04:00
|
|
|
assert_equal [2], hash.delete!(1) {called = true}
|
2014-10-23 08:42:57 -04:00
|
|
|
assert_equal false, called, "block called"
|
|
|
|
assert_equal 0, hash.size
|
2014-10-23 10:18:32 -04:00
|
|
|
assert_equal nil, hash.delete!(1) {called = true}
|
2014-10-23 08:42:57 -04:00
|
|
|
assert_equal false, called, "block called"
|
|
|
|
assert_equal 0, hash.size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|