From 673dc51c251588be3c9f4b5b5486cd80d46dfeee Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 7 Feb 2019 08:14:10 +0000 Subject: 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 --- test/ruby/test_enum.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby') 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)) -- cgit v1.2.3