Module: Hash::Compact::Etest

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

Instance Method Summary collapse

Instance Method Details

#test_compactObject


27
28
29
30
31
32
# File 'lib/vex/base/hash/compact.rb', line 27

def test_compact
  h = { 1 => nil }
  assert_equal(h.compact, {})
  h.compact!
  assert_equal(h, {})
end

#test_compact_2Object


34
35
36
37
# File 'lib/vex/base/hash/compact.rb', line 34

def test_compact_2
  h = { nil => 1 }
  assert_equal(h.compact, { nil => 1})
end

#test_compact_noObject


19
20
21
22
23
24
25
# File 'lib/vex/base/hash/compact.rb', line 19

def test_compact_no
  h = { 1 => 2 }
  assert_equal(h.compact, h)
  assert_not_equal(h.compact.object_id, h.object_id)
  assert_equal(h.compact!.object_id, h.object_id)
  assert_equal(h.compact!, h.compact)
end