diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-17 11:22:30 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-17 11:22:30 +0000 |
commit | f3b347e109f42f53ffc30f9e6e10be4b4f285916 (patch) | |
tree | db1a57b05fe581ef94e5fc6c7e44f461a83c765f /spec/ruby/core/numeric/step_spec.rb | |
parent | 5032f6377b68f01bef7bc0c8c58b3e7c375119a9 (diff) |
Add version guards for Enumerator::ArithmeticSequence
* And keep specs for older versions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/numeric/step_spec.rb')
-rw-r--r-- | spec/ruby/core/numeric/step_spec.rb | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/spec/ruby/core/numeric/step_spec.rb b/spec/ruby/core/numeric/step_spec.rb index 54133f8810..1eb91aa1e5 100644 --- a/spec/ruby/core/numeric/step_spec.rb +++ b/spec/ruby/core/numeric/step_spec.rb @@ -22,24 +22,43 @@ describe "Numeric#step" do it_behaves_like :numeric_step, :step describe "when no block is given" do - it "returns an Enumerator when step is 0" do - 1.step(5, 0).should be_an_instance_of(Enumerator::ArithmeticSequence) + step_enum_class = Enumerator + ruby_version_is "2.6" do + step_enum_class = Enumerator::ArithmeticSequence end - it "returns an Enumerator when step is 0.0" do - 1.step(2, 0.0).should be_an_instance_of(Enumerator::ArithmeticSequence) + it "returns an #{step_enum_class} when step is 0" do + 1.step(5, 0).should be_an_instance_of(step_enum_class) end - describe "returned Enumerator" do + it "returns an #{step_enum_class} when step is 0.0" do + 1.step(2, 0.0).should be_an_instance_of(step_enum_class) + end + + describe "returned #{step_enum_class}" do describe "size" do - it "raises an ArgumentError when step is 0" do - enum = 1.step(5, 0) - enum.size.should == Float::INFINITY + ruby_version_is ""..."2.6" do + it "raises an ArgumentError when step is 0" do + enum = 1.step(5, 0) + lambda { enum.size }.should raise_error(ArgumentError) + end + + it "raises an ArgumentError when step is 0.0" do + enum = 1.step(2, 0.0) + lambda { enum.size }.should raise_error(ArgumentError) + end end - it "raises an ArgumentError when step is 0.0" do - enum = 1.step(2, 0.0) - enum.size.should == Float::INFINITY + ruby_version_is "2.6" do + it "is infinity when step is 0" do + enum = 1.step(5, 0) + enum.size.should == Float::INFINITY + end + + it "is infinity when step is 0.0" do + enum = 1.step(2, 0.0) + enum.size.should == Float::INFINITY + end end end end |