mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@4ce9f41
This commit is contained in:
parent
267bed0cd9
commit
727c97da19
108 changed files with 1325 additions and 270 deletions
|
@ -486,7 +486,7 @@ describe :array_slice, shared: true do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a RangeError when the start index is out of range of Integer" do
|
||||
it "raises a RangeError when the start index is out of range of Fixnum" do
|
||||
array = [1, 2, 3, 4, 5, 6]
|
||||
obj = mock('large value')
|
||||
obj.should_receive(:to_int).and_return(bignum_value)
|
||||
|
@ -502,7 +502,7 @@ describe :array_slice, shared: true do
|
|||
array.send(@method, max_long.to_f.prev_float).should == nil
|
||||
end
|
||||
|
||||
it "raises a RangeError when the length is out of range of Integer" do
|
||||
it "raises a RangeError when the length is out of range of Fixnum" do
|
||||
array = [1, 2, 3, 4, 5, 6]
|
||||
obj = mock('large value')
|
||||
obj.should_receive(:to_int).and_return(bignum_value)
|
||||
|
@ -520,4 +520,41 @@ describe :array_slice, shared: true do
|
|||
-> { "hello".send(@method, bignum_value..(bignum_value + 1)) }.should raise_error(RangeError)
|
||||
-> { "hello".send(@method, 0..bignum_value) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
it "can accept endless ranges" do
|
||||
a = [0, 1, 2, 3, 4, 5]
|
||||
a.send(@method, eval("(2..)")).should == [2, 3, 4, 5]
|
||||
a.send(@method, eval("(2...)")).should == [2, 3, 4, 5]
|
||||
a.send(@method, eval("(-2..)")).should == [4, 5]
|
||||
a.send(@method, eval("(-2...)")).should == [4, 5]
|
||||
a.send(@method, eval("(9..)")).should == nil
|
||||
a.send(@method, eval("(9...)")).should == nil
|
||||
a.send(@method, eval("(-9..)")).should == nil
|
||||
a.send(@method, eval("(-9...)")).should == nil
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.7" do
|
||||
it "can accept beginless ranges" do
|
||||
a = [0, 1, 2, 3, 4, 5]
|
||||
a.send(@method, eval("(..3)")).should == [0, 1, 2, 3]
|
||||
a.send(@method, eval("(...3)")).should == [0, 1, 2]
|
||||
a.send(@method, eval("(..-3)")).should == [0, 1, 2, 3]
|
||||
a.send(@method, eval("(...-3)")).should == [0, 1, 2]
|
||||
a.send(@method, eval("(..0)")).should == [0]
|
||||
a.send(@method, eval("(...0)")).should == []
|
||||
a.send(@method, eval("(..9)")).should == [0, 1, 2, 3, 4, 5]
|
||||
a.send(@method, eval("(...9)")).should == [0, 1, 2, 3, 4, 5]
|
||||
a.send(@method, eval("(..-9)")).should == []
|
||||
a.send(@method, eval("(...-9)")).should == []
|
||||
end
|
||||
|
||||
it "can accept nil...nil ranges" do
|
||||
a = [0, 1, 2, 3, 4, 5]
|
||||
a.send(@method, eval("(nil...nil)")).should == a
|
||||
a.send(@method, eval("(...nil)")).should == a
|
||||
a.send(@method, eval("(nil..)")).should == a
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue