Module: Hash::Extras::Etest

Defined in:
lib/vex/base/hash/extras.rb

Instance Method Summary collapse

Instance Method Details

#test_createObject



38
39
40
41
42
# File 'lib/vex/base/hash/extras.rb', line 38

def test_create
  h = Hash.create([:a, :b], ["aa", "bb"])
  
  assert_equal({ :a => "aa", :b => "bb"}, h)
end

#test_delete_allObject



49
50
51
52
53
# File 'lib/vex/base/hash/extras.rb', line 49

def test_delete_all
  h = { 1 => "a", 2 => "b" }
  assert_equal([ "a", nil ], h.delete_all(1, 3))
  assert_equal({ 2 => "b"}, h)
end

#test_hmapObject



44
45
46
47
# File 'lib/vex/base/hash/extras.rb', line 44

def test_hmap
  h = { 1 => "a", 2 => "b" }
  assert_equal({ 1 => "a", 2 => "bb"}, h.hmap do |k,v| v * k end)
end

#test_selectObject



55
56
57
58
59
60
61
# File 'lib/vex/base/hash/extras.rb', line 55

def test_select
  h = { 1 => "a", 2 => "b" }
  h_orig = h.dup
  
  assert_equal([ "a", nil ], h.select_entries(1, 3))
  assert_equal(h_orig, h)
end