diff options
| author | Daniel Bovensiepen <[email protected]> | 2012-06-02 23:39:00 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2012-06-02 23:39:00 +0800 |
| commit | 2c58690df132a462619d62f85963cc5a330a1378 (patch) | |
| tree | 29355c6906a6f063d2e404f29b919e4f68697cce /test | |
| parent | ecbaf9cd99803a2fa121fe6aabea74590a36e0b2 (diff) | |
| download | mruby-2c58690df132a462619d62f85963cc5a330a1378.tar.gz mruby-2c58690df132a462619d62f85963cc5a330a1378.zip | |
Add test cases for Hash
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/hash.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/t/hash.rb b/test/t/hash.rb index af662688a..df21dd1fa 100644 --- a/test/t/hash.rb +++ b/test/t/hash.rb @@ -224,3 +224,42 @@ assert('Hash#values', '15.2.13.4.28') do a.values == ['abc_value'] end + +# Not ISO specified + +assert('Hash#reject') do + h = {:one => 1, :two => 2, :three => 3, :four => 4} + ret = h.reject do |k,v| + v % 2 == 0 + end + ret == {:one => 1, :three => 3} and + h == {:one => 1, :two => 2, :three => 3, :four => 4} +end + +assert('Hash#reject!') do + h = {:one => 1, :two => 2, :three => 3, :four => 4} + ret = h.reject! do |k,v| + v % 2 == 0 + end + ret == {:one => 1, :three => 3} and + h == {:one => 1, :three => 3} +end + +assert('Hash#select') do + h = {:one => 1, :two => 2, :three => 3, :four => 4} + ret = h.select do |k,v| + v % 2 == 0 + end + ret == {:two => 2, :four => 4} and + h == {:one => 1, :two => 2, :three => 3, :four => 4} +end + +assert('Hash#select!') do + h = {:one => 1, :two => 2, :three => 3, :four => 4} + ret = h.select! do |k,v| + v % 2 == 0 + end + ret == {:two => 2, :four => 4} and + h == {:two => 2, :four => 4} +end + |
