diff options
author | Benoit Daloze <[email protected]> | 2021-06-02 14:34:07 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2021-06-02 14:34:07 +0200 |
commit | 22e2a6a999b958efe5d84d9c7314e450fda82254 (patch) | |
tree | b2dc946cf2fe2c250d0583675e548c67dca3e71a /spec/ruby/core/range | |
parent | a4fbc7e2884ba694278adea3b32ddb8c2ac10efe (diff) |
Update to ruby/spec@a0b7d0d
Diffstat (limited to 'spec/ruby/core/range')
-rw-r--r-- | spec/ruby/core/range/step_spec.rb | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/spec/ruby/core/range/step_spec.rb b/spec/ruby/core/range/step_spec.rb index 1c2e30742c..be4b482654 100644 --- a/spec/ruby/core/range/step_spec.rb +++ b/spec/ruby/core/range/step_spec.rb @@ -207,11 +207,17 @@ 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 } + ScratchPad.recorded.should eql([1.0, 2.8, 4.6]) + end + 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 } + it "correctly handles values near the upper limit" do # https://bugs.ruby-lang.org/issues/16612 (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]) + ScratchPad.recorded.should eql([1.0, 19.2, 37.4, 55.599999999999994]) + + (1.0...55.6).step(18.2).size.should == 4 end end @@ -459,21 +465,18 @@ describe "Range#step" do (-1.0...1.0).step(0.5).size.should == 4 end - 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 + 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 end it "returns nil with begin and end are String" do |