Sha256: 3f7c6c361dab4658906d3d0c5e7897f2e79ab26554832e34d981eab11522e401

Contents?: true

Size: 678 Bytes

Versions: 23

Compression:

Stored size: 678 Bytes

Contents

describe "Array#replace" do
  it "replaces the elements with elements from other array" do
    a = [1, 2, 3, 4, 5]
    b = ['a', 'b', 'c']
    a.replace(b).should equal(a)
    a.should == b
    a.should_not equal(b)

    a.replace([4] * 10)
    a.should == [4] * 10

    a.replace([])
    a.should == []
  end

  it "returns self" do
    ary = [1, 2, 3]
    other = [:a, :b, :c]
    ary.replace(other).should equal(ary)
  end

  it "does not make self dependent to the original array" do
    ary = [1, 2, 3]
    other = [:a, :b, :c]
    ary.replace(other)
    ary.should == [:a, :b, :c]
    ary << :d
    ary.should == [:a, :b, :c, :d]
    other.should == [:a, :b, :c]
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

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