diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-07 08:14:10 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-07 08:14:10 +0000 |
commit | 673dc51c251588be3c9f4b5b5486cd80d46dfeee (patch) | |
tree | 9e26efcb7b1858e6fb477f28b229b8326301adad /test/ruby | |
parent | e0f1b514d2f78fe5ea17ddf240307cafbf47fccf (diff) | |
download | ruby-673dc51c251588be3c9f4b5b5486cd80d46dfeee.tar.gz |
enum.c: Enumerable#tally
* enum.c (enum_tally): new methods Enumerable#tally, which group
and count elements of the collection. [Feature #11076]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_enum.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index c56e280e06..1029143db6 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -294,6 +294,11 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(h, @obj.each_with_index.group_by(&cond)) end + def test_tally + h = {1 => 2, 2 => 2, 3 => 1} + assert_equal(h, @obj.tally) + end + def test_first assert_equal(1, @obj.first) assert_equal([1, 2, 3], @obj.first(3)) |