ruby-changes:55942
From: Benoit <ko1@a...>
Date: Sat, 1 Jun 2019 02:03:25 +0900 (JST)
Subject: [ruby-changes:55942] Benoit Daloze: 1d37cc1900 (trunk): Update to ruby/spec@cfe908c
https://git.ruby-lang.org/ruby.git/commit/?id=1d37cc1900 From 1d37cc1900b6cf13285417577cb21c01195d3d2a Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Fri, 31 May 2019 19:02:08 +0200 Subject: Update to ruby/spec@cfe908c diff --git a/spec/ruby/core/enumerable/tally_spec.rb b/spec/ruby/core/enumerable/tally_spec.rb new file mode 100644 index 0000000..363b3de --- /dev/null +++ b/spec/ruby/core/enumerable/tally_spec.rb @@ -0,0 +1,35 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/tally_spec.rb#L1 +require_relative '../../spec_helper' +require_relative 'fixtures/classes' + +ruby_version_is "2.7" do + describe "Enumerable#tally" do + before :each do + ScratchPad.record [] + end + + it "returns a hash with counts according to the value" do + enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz') + enum.tally.should == { 'foo' => 2, 'bar' => 1, 'baz' => 1} + end + + it "returns a hash without default" do + hash = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz').tally + hash.default_proc.should be_nil + hash.default.should be_nil + end + + it "returns an empty hash for empty enumerables" do + EnumerableSpecs::Empty.new.tally.should == {} + end + + it "counts values as gathered array when yielded with multiple arguments" do + EnumerableSpecs::YieldsMixed2.new.tally.should == EnumerableSpecs::YieldsMixed2.gathered_yields.group_by(&:itself).transform_values(&:size) + end + + it "does not call given block" do + enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz') + enum.tally { |v| ScratchPad << v } + ScratchPad.recorded.should == [] + end + end +end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/