Skip to content
This repository
Browse code

Merge pull request #232 from bovi/add-hash-tests

Add test cases for Hash
  • Loading branch information...
commit 79ad340c44f0521f96eb87252784df1a762e5869 2 parents 1c926e8 + 2c58690
Yukihiro "Matz" Matsumoto authored June 02, 2012

Showing 1 changed file with 39 additions and 0 deletions. Show diff stats Hide diff stats

  1. 39  test/t/hash.rb
39  test/t/hash.rb
@@ -224,3 +224,42 @@
224 224
 
225 225
   a.values == ['abc_value']
226 226
 end
  227
+
  228
+# Not ISO specified
  229
+
  230
+assert('Hash#reject') do
  231
+  h = {:one => 1, :two => 2, :three => 3, :four => 4}
  232
+  ret = h.reject do |k,v|
  233
+    v % 2 == 0
  234
+  end
  235
+  ret == {:one => 1, :three => 3} and
  236
+    h == {:one => 1, :two => 2, :three => 3, :four => 4}
  237
+end
  238
+
  239
+assert('Hash#reject!') do
  240
+  h = {:one => 1, :two => 2, :three => 3, :four => 4}
  241
+  ret = h.reject! do |k,v|
  242
+    v % 2 == 0
  243
+  end
  244
+  ret == {:one => 1, :three => 3} and
  245
+    h == {:one => 1, :three => 3}
  246
+end
  247
+
  248
+assert('Hash#select') do
  249
+  h = {:one => 1, :two => 2, :three => 3, :four => 4}
  250
+  ret = h.select do |k,v|
  251
+    v % 2 == 0
  252
+  end
  253
+  ret == {:two => 2, :four => 4} and
  254
+    h == {:one => 1, :two => 2, :three => 3, :four => 4}
  255
+end
  256
+
  257
+assert('Hash#select!') do
  258
+  h = {:one => 1, :two => 2, :three => 3, :four => 4}
  259
+  ret = h.select! do |k,v|
  260
+    v % 2 == 0
  261
+  end
  262
+  ret == {:two => 2, :four => 4} and
  263
+    h == {:two => 2, :four => 4}
  264
+end
  265
+

0 notes on commit 79ad340

Please sign in to comment.
Something went wrong with that request. Please try again.