1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2020-02-28 19:07:17 +01:00
parent 5d21050182
commit a0f5ff4c3c
75 changed files with 851 additions and 143 deletions

View file

@ -121,6 +121,8 @@ describe :string_slice_index_length, shared: true do
"x".send(@method, -2,0).should == nil
"x".send(@method, -2,1).should == nil
"x".send(@method, fixnum_max, 1).should == nil
end
it "returns nil if the length is negative" do
@ -293,6 +295,24 @@ describe :string_slice_range, shared: true do
"hello world".send(@method, 6..5).send(@method, -1..-1).should == nil
"hello world".send(@method, 6..5).send(@method, 1..1).should == nil
end
it "raises a type error if a range is passed with a length" do
->{ "hello".send(@method, 1..2, 1) }.should raise_error(TypeError)
end
it "raises a RangeError if one of the bound is too big" 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 "works with endless ranges" do
"hello there".send(@method, eval("(2..)")).should == "llo there"
"hello there".send(@method, eval("(2...)")).should == "llo there"
"hello there".send(@method, eval("(-4..)")).should == "here"
"hello there".send(@method, eval("(-4...)")).should == "here"
end
end
end
describe :string_slice_regexp, shared: true do