summaryrefslogtreecommitdiff
path: root/spec/ruby/core/range/step_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2021-11-29 15:50:28 +0100
committerBenoit Daloze <eregontp@gmail.com>2021-11-29 15:50:28 +0100
commit67a1e2258974df4b597d019739595c18fbb9a7c1 (patch)
tree992ad4fc0fc08a6af8f04373703a339f957eb143 /spec/ruby/core/range/step_spec.rb
parente6d93a27afa058319e6dad093bbef637e49fce47 (diff)
Update to ruby/spec@7f22a0b
Diffstat (limited to 'spec/ruby/core/range/step_spec.rb')
-rw-r--r--spec/ruby/core/range/step_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/ruby/core/range/step_spec.rb b/spec/ruby/core/range/step_spec.rb
index 624fa71f5f..4c69073854 100644
--- a/spec/ruby/core/range/step_spec.rb
+++ b/spec/ruby/core/range/step_spec.rb
@@ -481,6 +481,32 @@ describe "Range#step" do
end
end
+ ruby_version_is "2.7" do
+ context "when begin is not defined and end is numeric" do
+ it "returns an instance of Enumerator::ArithmeticSequence" do
+ eval("(..10)").step.class.should == Enumerator::ArithmeticSequence
+ end
+ end
+ end
+
+ context "when range is endless" do
+ it "returns an instance of Enumerator::ArithmeticSequence when begin is numeric" do
+ (1..).step.class.should == Enumerator::ArithmeticSequence
+ end
+
+ it "returns an instance of Enumerator when begin is not numeric" do
+ ("a"..).step.class.should == Enumerator
+ end
+ end
+
+ ruby_version_is "2.7" do
+ context "when range is beginless and endless" do
+ it "returns an instance of Enumerator" do
+ Range.new(nil, nil).step.class.should == Enumerator
+ end
+ end
+ end
+
context "when begin and end are not numerics" do
it "returns an instance of Enumerator" do
("a".."z").step.class.should == Enumerator