summaryrefslogtreecommitdiff
path: root/spec/ruby/core/range/step_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/range/step_spec.rb')
-rw-r--r--spec/ruby/core/range/step_spec.rb38
1 files changed, 21 insertions, 17 deletions
diff --git a/spec/ruby/core/range/step_spec.rb b/spec/ruby/core/range/step_spec.rb
index e284551ab3..1c2e30742c 100644
--- a/spec/ruby/core/range/step_spec.rb
+++ b/spec/ruby/core/range/step_spec.rb
@@ -207,10 +207,12 @@ describe "Range#step" do
ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5])
end
- it "returns Float values of 'step * n + begin < end'" do
- (1.0...6.4).step(1.8) { |x| ScratchPad << x }
- (1.0...55.6).step(18.2) { |x| ScratchPad << x }
- ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 1.0, 19.2, 37.4])
+ ruby_version_is '3.1' do
+ it "returns Float values of 'step * n + begin < end'" do
+ (1.0...6.4).step(1.8) { |x| ScratchPad << x }
+ (1.0...55.6).step(18.2) { |x| ScratchPad << x }
+ ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 1.0, 19.2, 37.4, 55.599999999999994])
+ end
end
it "handles infinite values at either end" do
@@ -457,19 +459,21 @@ describe "Range#step" do
(-1.0...1.0).step(0.5).size.should == 4
end
- it "returns the range size when there's no step_size" do
- (-2..2).step.size.should == 5
- (-2.0..2.0).step.size.should == 5
- (-2..2.0).step.size.should == 5
- (-2.0..2).step.size.should == 5
- (1.0..6.4).step(1.8).size.should == 4
- (1.0..12.7).step(1.3).size.should == 10
- (-2...2).step.size.should == 4
- (-2.0...2.0).step.size.should == 4
- (-2...2.0).step.size.should == 4
- (-2.0...2).step.size.should == 4
- (1.0...6.4).step(1.8).size.should == 3
- (1.0...55.6).step(18.2).size.should == 3
+ ruby_version_is '3.1' do
+ it "returns the range size when there's no step_size" do
+ (-2..2).step.size.should == 5
+ (-2.0..2.0).step.size.should == 5
+ (-2..2.0).step.size.should == 5
+ (-2.0..2).step.size.should == 5
+ (1.0..6.4).step(1.8).size.should == 4
+ (1.0..12.7).step(1.3).size.should == 10
+ (-2...2).step.size.should == 4
+ (-2.0...2.0).step.size.should == 4
+ (-2...2.0).step.size.should == 4
+ (-2.0...2).step.size.should == 4
+ (1.0...6.4).step(1.8).size.should == 3
+ (1.0...55.6).step(18.2).size.should == 4
+ end
end
it "returns nil with begin and end are String" do