summaryrefslogtreecommitdiff
path: root/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb
blob: 00403b02389fa1606fa21296223540b1b3f144bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require_relative '../../../spec_helper'

ruby_version_is "2.6" do
  describe "Enumerator::ArithmeticSequence#size" do
    context "for finite sequence" do
      it "returns the number of elements in this arithmetic sequence" do
        1.step(10).size.should == 10
        (1...10).step.size.should == 9
      end
    end

    context "for infinite sequence" do
      it "returns Infinity" do
        1.step(Float::INFINITY).size.should == Float::INFINITY
        (1..Float::INFINITY).step.size.should == Float::INFINITY
      end
    end
  end
end