Sha256: ff64e8f1335c5ded2e603d098dcc0e3f512df71af2d70bba45b35ffbebb08858

Contents?: true

Size: 654 Bytes

Versions: 23

Compression:

Stored size: 654 Bytes

Contents

describe "Array#delete_at" do
  it "removes the element at the specified index" do
    a = [1, 2, 3, 4]
    a.delete_at(2)
    a.should == [1, 2, 4]
    a.delete_at(-1)
    a.should == [1, 2]
  end

  it "returns the removed element at the specified index" do
    a = [1, 2, 3, 4]
    a.delete_at(2).should == 3
    a.delete_at(-1).should == 4
  end

  it "returns nil and makes no modification if the index is out of range" do
    a = [1, 2]
    a.delete_at(3).should == nil
    a.should == [1, 2]
    a.delete_at(-3).should == nil
    a.should == [1, 2]
  end

  it "accepts negative indices" do
    a = [1, 2]
    a.delete_at(-2).should == 1
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/delete_at_spec.rb
opal-0.3.40 spec/core/array/delete_at_spec.rb
opal-0.3.39 spec/core/array/delete_at_spec.rb
opal-0.3.38 spec/core/array/delete_at_spec.rb
opal-0.3.37 spec/core/array/delete_at_spec.rb
opal-0.3.36 spec/core/array/delete_at_spec.rb
opal-0.3.35 spec/core/array/delete_at_spec.rb
opal-0.3.34 spec/core/array/delete_at_spec.rb
opal-0.3.33 spec/core/array/delete_at_spec.rb
opal-0.3.32 spec/core/array/delete_at_spec.rb
opal-0.3.31 spec/core/array/delete_at_spec.rb
opal-0.3.30 spec/core/array/delete_at_spec.rb
opal-0.3.29 spec/core/array/delete_at_spec.rb
opal-0.3.28 spec/core/array/delete_at_spec.rb
opal-0.3.27 spec/core/array/delete_at_spec.rb
opal-0.3.26 spec/core/array/delete_at_spec.rb
opal-0.3.25 spec/core/array/delete_at_spec.rb
opal-0.3.22 spec/core/array/delete_at_spec.rb
opal-0.3.21 test/core/array/delete_at_spec.rb
opal-0.3.20 test/core/array/delete_at_spec.rb