summaryrefslogtreecommitdiffhomepage
path: root/test/t/hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/t/hash.rb')
-rw-r--r--test/t/hash.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/t/hash.rb b/test/t/hash.rb
index af662688a..04a9a1c24 100644
--- a/test/t/hash.rb
+++ b/test/t/hash.rb
@@ -5,6 +5,10 @@ assert('Hash', '15.2.13') do
Hash.class == Class
end
+assert('Hash superclass', '15.2.13.2') do
+ Hash.superclass == Object
+end
+
assert('Hash#==', '15.2.13.4.1') do
({ 'abc' => 'abc' } == { 'abc' => 'abc' }) and
not ({ 'abc' => 'abc' } == { 'cba' => 'cba' })
@@ -224,3 +228,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
+