diff options
author | Andrew Konchin <[email protected]> | 2025-03-26 19:56:40 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2025-03-27 11:09:24 +0100 |
commit | bac22c985ecc7e4309b5b5e5ae1074c81319e889 (patch) | |
tree | 5c164d3ed99240737205068f612d47496487758e /spec/ruby/core/string/shared | |
parent | 53a930f1570c81d2f7829f932e8d7ad67e8462b8 (diff) |
Update to ruby/spec@5e579e2
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12984
Diffstat (limited to 'spec/ruby/core/string/shared')
-rw-r--r-- | spec/ruby/core/string/shared/slice.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 2f69b9ddce..7b9b9f6a14 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -119,6 +119,18 @@ describe :string_slice_index_length, shared: true do "hello there".send(@method, -4,-3).should == nil end + platform_is pointer_size: 64 do + it "returns nil if the length is negative big value" do + "hello there".send(@method, 4, -(1 << 31)).should == nil + + # by some reason length < -(1 << 31) on CI on Windows leads to + # 'RangeError: bignum too big to convert into `long'' error + platform_is_not :windows do + "hello there".send(@method, 4, -(1 << 63)).should == nil + end + end + end + it "calls to_int on the given index and the given length" do "hello".send(@method, 0.5, 1).should == "h" "hello".send(@method, 0.5, 2.5).should == "he" @@ -152,6 +164,11 @@ describe :string_slice_index_length, shared: true do -> { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError) end + it "raises a RangeError if the index or length is too small" do + -> { "hello".send(@method, -bignum_value, 1) }.should raise_error(RangeError) + -> { "hello".send(@method, 0, -bignum_value) }.should raise_error(RangeError) + end + it "returns String instances" do s = StringSpecs::MyString.new("hello") s.send(@method, 0,0).should be_an_instance_of(String) |