diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-12-27 17:35:32 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-12-27 17:35:32 +0100 |
commit | 727c97da1977544c91b9b3677811da3a44af7d53 (patch) | |
tree | 4f027117edad10789db57ff4b83242753a89e39d /spec/ruby/core/array/slice_spec.rb | |
parent | 267bed0cd91711e2a8c79219e97431ba22137b01 (diff) |
Update to ruby/spec@4ce9f41
Diffstat (limited to 'spec/ruby/core/array/slice_spec.rb')
-rw-r--r-- | spec/ruby/core/array/slice_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/ruby/core/array/slice_spec.rb b/spec/ruby/core/array/slice_spec.rb index 3829794938..f416d8d0ce 100644 --- a/spec/ruby/core/array/slice_spec.rb +++ b/spec/ruby/core/array/slice_spec.rb @@ -163,6 +163,26 @@ describe "Array#slice!" do a = [1, 2, 3] a.slice!(eval("(2...)")).should == [3] a.should == [1, 2] + + a = [1, 2, 3] + a.slice!(eval("(-2..)")).should == [2, 3] + a.should == [1] + + a = [1, 2, 3] + a.slice!(eval("(-1...)")).should == [3] + a.should == [1, 2] + end + end + + ruby_version_is "2.7" do + it "works with beginless ranges" do + a = [0,1,2,3,4] + a.slice!(eval("(..3)")).should == [0, 1, 2, 3] + a.should == [4] + + a = [0,1,2,3,4] + a.slice!(eval("(...-2)")).should == [0, 1, 2] + a.should == [3, 4] end end end |