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

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