diff options
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index edc0eeebee..7720b6098e 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -354,6 +354,14 @@ class TestHash < Test::Unit::TestCase assert_equal({1=>2,3=>4,5=>6}, h.keep_if{true}) end + def test_compact + h = @cls[a: 1, b: nil, c: false, d: true, e: nil] + assert_equal({a: 1, c: false, d: true}, h.compact) + assert_equal({a: 1, b: nil, c: false, d: true, e: nil}, h) + h.compact! + assert_equal({a: 1, c: false, d: true}, h) + end + def test_dup for taint in [ false, true ] for frozen in [ false, true ] |