HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-3.0.2/spec/ruby/core/enumerator/chain/size_spec.rb
require_relative '../../../spec_helper'
require_relative '../../enumerable/fixtures/classes'

ruby_version_is "2.6" do
  describe "Enumerator::Chain#size" do
    it "returns the sum of the sizes of the elements" do
      a = mock('size')
      a.should_receive(:size).and_return(40)
      Enumerator::Chain.new(a, [:a, :b]).size.should == 42
    end

    it "returns nil or Infinity for the first element of such a size" do
      [nil, Float::INFINITY].each do |special|
        a = mock('size')
        a.should_receive(:size).and_return(40)
        b = mock('special')
        b.should_receive(:size).and_return(special)
        c = mock('not called')
        c.should_not_receive(:size)
        Enumerator::Chain.new(a, b, c).size.should == special
      end
    end
  end
end