diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-06-02 10:13:05 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-06-02 10:13:05 -0700 |
| commit | 79ad340c44f0521f96eb87252784df1a762e5869 (patch) | |
| tree | 5641e28ec671d2662c48e6a0da8cad205f8e0660 | |
| parent | 1c926e852ed85d1bffad83a0f4b650c0575c325d (diff) | |
| parent | 2c58690df132a462619d62f85963cc5a330a1378 (diff) | |
| download | mruby-79ad340c44f0521f96eb87252784df1a762e5869.tar.gz mruby-79ad340c44f0521f96eb87252784df1a762e5869.zip | |
Merge pull request #232 from bovi/add-hash-tests
Add test cases for Hash
| -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 + |
