mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enum.c (count_i, count_iter_i): Sync with trunk.
enum.c (enum_count, count_all_i, Init_Enumerable), array.c (rb_ary_count): Sync with trunk. If no argument or block is given, count the number of all elements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
019864bfc1
commit
14dd72b35a
6 changed files with 72 additions and 38 deletions
|
@ -530,6 +530,7 @@ class TestArray < Test::Unit::TestCase
|
|||
|
||||
def test_count
|
||||
a = @cls[1, 2, 3, 1, 2]
|
||||
assert_equal(5, a.count)
|
||||
assert_equal(2, a.count(1))
|
||||
assert_equal(3, a.count {|x| x % 2 == 1 })
|
||||
assert_equal(2, a.count(1) {|x| x % 2 == 1 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue