Permalink
Browse files

Document find_all. Add type check assertions.

  • Loading branch information...
1 parent d53fdb5 commit 2d43df9345a61b31d25e691e988a04983ee8fb0b @gmallard committed Sep 13, 2010
Showing with 13 additions and 2 deletions.
  1. +13 −2 test/TestPersonColl.rb
@@ -399,10 +399,21 @@ def test_180_to_a
def test_190_find_all
@@log.debug "test_190_find_all starts" if @@log.debug?
assert_respond_to(@list, :find_all, "test_190_find_all_respond")
-
+ # Basic find_all check
ta = @list.find_all {|obj| obj.first <= "Bob" }
assert_equal([@aen, @bsb], ta, "test_190_find_all_eq01")
-
+ # Check Enumerator or Enumerable::Enumerator return, no block given
+ new_list = @list.find_all
+if RUBY_VERSION =~ /(1.9)|(2.)/
+ result = new_list.is_a? Enumerator
+ assert(result, "test_190_find_all_enumcheck")
+else
+ # Note: the author's version of the 1.8 Pickaxe documents this
+ # as an Array. Testing with 1.8.7 however, shows this to be
+ # incorrect. YMMV.
+ result = new_list.is_a? Enumerable::Enumerator
+ assert(result, "test_190_find_all_enumenumcheck")
+end
@@log.debug "test_190_find_all ends" if @@log.debug?
end

0 comments on commit 2d43df9

Please sign in to comment.