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

describe "Enumerator::ArithmeticSequence#begin" do
  it "returns the begin of the sequence" do
    1.step(10).begin.should == 1
    (1..10).step.begin.should == 1
    (1...10).step.begin.should == 1
  end

  ruby_version_is "2.7" do
    context "with beginless" do
      it "returns nil as begin of the sequence" do
        eval("(..10).step(1)").begin.should == nil
        eval("(...10).step(1)").begin.should == nil
      end
    end
  end
end