Project

General

Profile

Bug #15254 ยป array_slice_start_length_test.rb

Malakai97 (Bryan Hockey), 10/25/2018 09:43 PM

 
require "minitest/autorun"

describe Array do
before do
@array = [0,1,2,3,4]
end

describe "#slice" do
describe "inconsistencies starting in past the end" do
it { @array.slice(5,3).must_equal [] }
it { @array.slice(6,3).must_equal [] } # returns nil
it { @array.slice(100,3).must_equal [] } # returns nil
end

describe "failures when starting before the start" do
it { @array.slice(-5,1).must_equal [0] }
it { @array.slice(-5,5).must_equal @array }
it { @array.slice(-6,2).must_equal [0] } # returns nil
it { @array.slice(-6,6).must_equal @array } # returns nil
end
end

end
    (1-1/1)