PageRenderTime 79ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/test/-ext-/hash/test_delete.rb

http://github.com/ruby/ruby
Ruby | 20 lines | 18 code | 1 blank | 1 comment | 0 complexity | 37dd8049a59aaf75de651740017af553 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-3.0
  1. # frozen_string_literal: false
  2. require 'test/unit'
  3. require '-test-/hash'
  4. class Test_Hash < Test::Unit::TestCase
  5. class TestDelete < Test::Unit::TestCase
  6. def test_delete
  7. hash = Bug::Hash.new
  8. hash[1] = 2
  9. called = false
  10. assert_equal 1, hash.size
  11. assert_equal [2], hash.delete!(1) {called = true}
  12. assert_equal false, called, "block called"
  13. assert_equal 0, hash.size
  14. assert_equal nil, hash.delete!(1) {called = true}
  15. assert_equal false, called, "block called"
  16. assert_equal 0, hash.size
  17. end
  18. end
  19. end