diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-05 21:17:14 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-05 21:17:14 +0900 |
| commit | 02cabf8fa7aacb1063d73105dbcf59bccee87470 (patch) | |
| tree | 2648b732a7ad5120318a483d398024a482ac8304 /mrbgems/mruby-hash-ext/test/hash.rb | |
| parent | e620c666d9746713e341970fc6803277cc846e84 (diff) | |
| parent | dcad562f7364e68724c024e2969ee1f1957f7263 (diff) | |
| download | mruby-02cabf8fa7aacb1063d73105dbcf59bccee87470.tar.gz mruby-02cabf8fa7aacb1063d73105dbcf59bccee87470.zip | |
Merge pull request #2198 from suzukaze/add-hash.keep_if
Add Hash#keep_if
Diffstat (limited to 'mrbgems/mruby-hash-ext/test/hash.rb')
| -rw-r--r-- | mrbgems/mruby-hash-ext/test/hash.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb index 10880666e..1334522ff 100644 --- a/mrbgems/mruby-hash-ext/test/hash.rb +++ b/mrbgems/mruby-hash-ext/test/hash.rb @@ -95,3 +95,10 @@ assert("Hash#invert") do assert_include(%w[a c], h[1]) assert_equal('b', h[2]) end + +assert("Hash#keep_if") do + h = { 1 => 2, 3 => 4, 5 => 6 } + assert_equal({3=>4,5=>6}, h.keep_if {|k, v| k + v >= 7 }) + h = { 1 => 2, 3 => 4, 5 => 6 } + assert_equal({ 1 => 2, 3=> 4, 5 =>6} , h.keep_if { true }) +end |
