From 9143d21b1bf2f16b1e847d569a588510726d8860 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 26 Mar 2021 16:29:21 +0900 Subject: Enumerable#tally with the resulting hash [Feature #17744] --- test/ruby/test_enum.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 3b0e0f79b2..b6d96f1379 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -394,6 +394,17 @@ class TestEnumerable < Test::Unit::TestCase def test_tally h = {1 => 2, 2 => 2, 3 => 1} assert_equal(h, @obj.tally) + + h = {1 => 5, 2 => 2, 3 => 1, 4 => "x"} + assert_equal(h, @obj.tally({1 => 3, 4 => "x"})) + + assert_raise(TypeError) do + @obj.tally({1 => ""}) + end + + h = {1 => 2, 2 => 2, 3 => 1} + assert_equal(h, @obj.tally(Hash.new(100))) + assert_equal(h, @obj.tally(Hash.new {100})) end def test_first -- cgit v1.2.3