Sha256: a98f0746d25680778fb002bb53e232a3417feb56e2dca7355b108f3ed0b06923

Contents?: true

Size: 625 Bytes

Versions: 15

Compression:

Stored size: 625 Bytes

Contents

describe "Array#unshift" do
  it "prepends object to the original array" do
    a = [1, 2, 3]
    a.unshift("a").should equal(a)
    a.should == ['a', 1, 2, 3]
    a.unshift().should equal(a)
    a.should == ['a', 1, 2, 3]
    a.unshift(5, 4, 3)
    a.should == [5, 4, 3, 'a', 1, 2, 3]

    # shift all but one element
    a = [1, 2]
    a.shift
    a.unshift(3, 4)
    a.should == [3, 4, 2]

    # now shift all elements
    a.shift
    a.shift
    a.shift
    a.unshift(3, 4)
    a.should == [3, 4]
  end

  it "quietly ignores unshifting nothing" do
    [].unshift().should == []
    [].unshift(*[]).should == []
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/unshift_spec.rb
opal-0.3.40 spec/core/array/unshift_spec.rb
opal-0.3.39 spec/core/array/unshift_spec.rb
opal-0.3.38 spec/core/array/unshift_spec.rb
opal-0.3.37 spec/core/array/unshift_spec.rb
opal-0.3.36 spec/core/array/unshift_spec.rb
opal-0.3.35 spec/core/array/unshift_spec.rb
opal-0.3.34 spec/core/array/unshift_spec.rb
opal-0.3.33 spec/core/array/unshift_spec.rb
opal-0.3.32 spec/core/array/unshift_spec.rb
opal-0.3.31 spec/core/array/unshift_spec.rb
opal-0.3.30 spec/core/array/unshift_spec.rb
opal-0.3.29 spec/core/array/unshift_spec.rb
opal-0.3.28 spec/core/array/unshift_spec.rb
opal-0.3.27 spec/core/array/unshift_spec.rb