diff options
Diffstat (limited to 'mrbgems/mruby-hash-ext/test')
| -rw-r--r-- | mrbgems/mruby-hash-ext/test/hash.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb index 2ae88c307..ca4e346fb 100644 --- a/mrbgems/mruby-hash-ext/test/hash.rb +++ b/mrbgems/mruby-hash-ext/test/hash.rb @@ -82,6 +82,20 @@ assert('Hash#values_at') do assert_equal keys, h.values_at(*keys) end +assert('Hash#compact') do + h = { "cat" => "feline", "dog" => nil, "cow" => false } + + assert_equal({ "cat" => "feline", "cow" => false }, h.compact) + assert_equal({ "cat" => "feline", "dog" => nil, "cow" => false }, h) +end + +assert('Hash#compact!') do + h = { "cat" => "feline", "dog" => nil, "cow" => false } + + h.compact! + assert_equal({ "cat" => "feline", "cow" => false }, h) +end + assert('Hash#fetch') do h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } assert_equal "feline", h.fetch("cat") |
