diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-03-26 16:29:21 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 16:29:21 +0900 |
commit | 9143d21b1bf2f16b1e847d569a588510726d8860 (patch) | |
tree | 8e2d3e939c64a5bd29c26e4416e753b89cfb5333 /test | |
parent | 6a352e275bfdad84bec479b84dd2bc6d76697226 (diff) |
Enumerable#tally with the resulting hash [Feature #17744]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4318
Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_enum.rb | 11 |
1 files changed, 11 insertions, 0 deletions
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 |