diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-07-29 22:11:21 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2021-07-29 22:11:21 +0200 |
commit | 6998d758248d778fa95b008c78d05473e48b8428 (patch) | |
tree | 8abc6926f647ea5f374a5b34c3a4820c5861e32e /spec/ruby/core/enumerator/arithmetic_sequence | |
parent | 15d05f8120745a121b93fab9fd2addf5f094e8d2 (diff) | |
download | ruby-6998d758248d778fa95b008c78d05473e48b8428.tar.gz |
Update to ruby/spec@b65d01f
Diffstat (limited to 'spec/ruby/core/enumerator/arithmetic_sequence')
12 files changed, 103 insertions, 127 deletions
diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb index c8d91ebaec..bed30c546d 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/begin_spec.rb @@ -1,11 +1,9 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - 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 +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 end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb index d7edf3a21f..d4fff3e01f 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb @@ -1,19 +1,17 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#each" do - before :each do - ScratchPad.record [] - @seq = 1.step(10, 4) - end +describe "Enumerator::ArithmeticSequence#each" do + before :each do + ScratchPad.record [] + @seq = 1.step(10, 4) + end - it "calls given block on each item of the sequence" do - @seq.each { |item| ScratchPad << item } - ScratchPad.recorded.should == [1, 5, 9] - end + it "calls given block on each item of the sequence" do + @seq.each { |item| ScratchPad << item } + ScratchPad.recorded.should == [1, 5, 9] + end - it "returns self" do - @seq.each { |item| }.should equal(@seq) - end + it "returns self" do + @seq.each { |item| }.should equal(@seq) end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb index 5a436e8167..29e6e105cf 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/end_spec.rb @@ -1,11 +1,9 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#end" do - it "returns the end of the sequence" do - 1.step(10).end.should == 10 - (1..10).step.end.should == 10 - (1...10).step(17).end.should == 10 - end +describe "Enumerator::ArithmeticSequence#end" do + it "returns the end of the sequence" do + 1.step(10).end.should == 10 + (1..10).step.end.should == 10 + (1...10).step(17).end.should == 10 end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb index 7895f98047..77eed02d8b 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/eq_spec.rb @@ -1,20 +1,18 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#==" do - it "returns true if begin, end, step and exclude_end? are equal" do - 1.step(10).should == 1.step(10) - 1.step(10, 5).should == 1.step(10, 5) +describe "Enumerator::ArithmeticSequence#==" do + it "returns true if begin, end, step and exclude_end? are equal" do + 1.step(10).should == 1.step(10) + 1.step(10, 5).should == 1.step(10, 5) - (1..10).step.should == (1..10).step - (1...10).step(8).should == (1...10).step(8) + (1..10).step.should == (1..10).step + (1...10).step(8).should == (1...10).step(8) - # both have exclude_end? == false - (1..10).step(100).should == 1.step(10, 100) + # both have exclude_end? == false + (1..10).step(100).should == 1.step(10, 100) - ((1..10).step == (1..11).step).should == false - ((1..10).step == (1...10).step).should == false - ((1..10).step == (1..10).step(2)).should == false - end + ((1..10).step == (1..11).step).should == false + ((1..10).step == (1...10).step).should == false + ((1..10).step == (1..10).step(2)).should == false end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb index 5be189e993..021fe7d90f 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/exclude_end_spec.rb @@ -1,19 +1,17 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#exclude_end?" do - context "when created using Numeric#step" do - it "always returns false" do - 1.step(10).should_not.exclude_end? - 10.step(1).should_not.exclude_end? - end +describe "Enumerator::ArithmeticSequence#exclude_end?" do + context "when created using Numeric#step" do + it "always returns false" do + 1.step(10).should_not.exclude_end? + 10.step(1).should_not.exclude_end? end + end - context "when created using Range#step" do - it "mirrors range.exclude_end?" do - (1...10).step.should.exclude_end? - (1..10).step.should_not.exclude_end? - end + context "when created using Range#step" do + it "mirrors range.exclude_end?" do + (1...10).step.should.exclude_end? + (1..10).step.should_not.exclude_end? end end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb index 43c520d1f0..ccd02be020 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/first_spec.rb @@ -1,11 +1,9 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#first" do - it "returns the first element of the sequence" do - 1.step(10).first.should == 1 - (1..10).step.first.should == 1 - (1...10).step.first.should == 1 - end +describe "Enumerator::ArithmeticSequence#first" do + it "returns the first element of the sequence" do + 1.step(10).first.should == 1 + (1..10).step.first.should == 1 + (1...10).step.first.should == 1 end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb index 236f845f41..bdb308074b 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb @@ -1,22 +1,20 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#hash" do - it "is based on begin, end, step and exclude_end?" do - 1.step(10).hash.should be_an_instance_of(Integer) +describe "Enumerator::ArithmeticSequence#hash" do + it "is based on begin, end, step and exclude_end?" do + 1.step(10).hash.should be_an_instance_of(Integer) - 1.step(10).hash.should == 1.step(10).hash - 1.step(10, 5).hash.should == 1.step(10, 5).hash + 1.step(10).hash.should == 1.step(10).hash + 1.step(10, 5).hash.should == 1.step(10, 5).hash - (1..10).step.hash.should == (1..10).step.hash - (1...10).step(8).hash.should == (1...10).step(8).hash + (1..10).step.hash.should == (1..10).step.hash + (1...10).step(8).hash.should == (1...10).step(8).hash - # both have exclude_end? == false - (1..10).step(100).hash.should == 1.step(10, 100).hash + # both have exclude_end? == false + (1..10).step(100).hash.should == 1.step(10, 100).hash - ((1..10).step.hash == (1..11).step.hash).should == false - ((1..10).step.hash == (1...10).step.hash).should == false - ((1..10).step.hash == (1..10).step(2).hash).should == false - end + ((1..10).step.hash == (1..11).step.hash).should == false + ((1..10).step.hash == (1...10).step.hash).should == false + ((1..10).step.hash == (1..10).step(2).hash).should == false end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb index 21e64a6b58..b73b49d272 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/inspect_spec.rb @@ -1,22 +1,20 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#inspect" do - context 'when Numeric#step is used' do - it "returns '(begin.step(end{, step}))'" do - 1.step(10).inspect.should == "(1.step(10))" - 1.step(10, 3).inspect.should == "(1.step(10, 3))" - end +describe "Enumerator::ArithmeticSequence#inspect" do + context 'when Numeric#step is used' do + it "returns '(begin.step(end{, step}))'" do + 1.step(10).inspect.should == "(1.step(10))" + 1.step(10, 3).inspect.should == "(1.step(10, 3))" end + end - context 'when Range#step is used' do - it "returns '((range).step{(step)})'" do - (1..10).step.inspect.should == "((1..10).step)" - (1..10).step(3).inspect.should == "((1..10).step(3))" + context 'when Range#step is used' do + it "returns '((range).step{(step)})'" do + (1..10).step.inspect.should == "((1..10).step)" + (1..10).step(3).inspect.should == "((1..10).step(3))" - (1...10).step.inspect.should == "((1...10).step)" - (1...10).step(3).inspect.should == "((1...10).step(3))" - end + (1...10).step.inspect.should == "((1...10).step)" + (1...10).step(3).inspect.should == "((1...10).step(3))" end end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb index ebb20090fc..31f982b7c4 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/last_spec.rb @@ -1,11 +1,9 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#last" do - it "returns the last element of the sequence" do - 1.step(10).last.should == 10 - (1..10).step.last.should == 10 - (1...10).step(4).last.should == 9 - end +describe "Enumerator::ArithmeticSequence#last" do + it "returns the last element of the sequence" do + 1.step(10).last.should == 10 + (1..10).step.last.should == 10 + (1...10).step(4).last.should == 9 end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb index 7227581fb9..2015983826 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb @@ -1,19 +1,17 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence.new" do - it "is not defined" do - -> { - Enumerator::ArithmeticSequence.new - }.should raise_error(NoMethodError) - end +describe "Enumerator::ArithmeticSequence.new" do + it "is not defined" do + -> { + Enumerator::ArithmeticSequence.new + }.should raise_error(NoMethodError) end +end - describe "Enumerator::ArithmeticSequence.allocate" do - it "is not defined" do - -> { - Enumerator::ArithmeticSequence.allocate - }.should raise_error(TypeError, 'allocator undefined for Enumerator::ArithmeticSequence') - end +describe "Enumerator::ArithmeticSequence.allocate" do + it "is not defined" do + -> { + Enumerator::ArithmeticSequence.allocate + }.should raise_error(TypeError, 'allocator undefined for Enumerator::ArithmeticSequence') end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb index 00403b0238..7e03edd961 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/size_spec.rb @@ -1,19 +1,17 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#size" do - context "for finite sequence" do - it "returns the number of elements in this arithmetic sequence" do - 1.step(10).size.should == 10 - (1...10).step.size.should == 9 - end +describe "Enumerator::ArithmeticSequence#size" do + context "for finite sequence" do + it "returns the number of elements in this arithmetic sequence" do + 1.step(10).size.should == 10 + (1...10).step.size.should == 9 end + end - context "for infinite sequence" do - it "returns Infinity" do - 1.step(Float::INFINITY).size.should == Float::INFINITY - (1..Float::INFINITY).step.size.should == Float::INFINITY - end + context "for infinite sequence" do + it "returns Infinity" do + 1.step(Float::INFINITY).size.should == Float::INFINITY + (1..Float::INFINITY).step.size.should == Float::INFINITY end end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb index 8b00fd4309..c1f2d9173f 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/step_spec.rb @@ -1,13 +1,11 @@ require_relative '../../../spec_helper' -ruby_version_is "2.6" do - describe "Enumerator::ArithmeticSequence#step" do - it "returns the original value given to step method" do - (1..10).step.step.should == 1 - (1..10).step(3).step.should == 3 +describe "Enumerator::ArithmeticSequence#step" do + it "returns the original value given to step method" do + (1..10).step.step.should == 1 + (1..10).step(3).step.should == 3 - 1.step(10).step.should == 1 - 1.step(10, 3).step.should == 3 - end + 1.step(10).step.should == 1 + 1.step(10, 3).step.should == 3 end end |