Sha256: 6024d470cb27902e20cd46d1c6705a392cd4af04d5c4079b5862af88805912f3

Contents?: true

Size: 427 Bytes

Versions: 23

Compression:

Stored size: 427 Bytes

Contents

describe "Array#dup" do
  it "produces a shallow copy where the references are directly copied" do
    a = [mock('1'), mock('2')]
    b = a.dup
    b.first.object_id.should == a.first.object_id
    b.last.object_id.should == a.last.object_id
  end

  it "creates a new array containing all the elements of the original" do
    a = [1, 2, 3, 4]
    b = a.dup
    b.should == a
    b.object_id.should_not == a.object_id
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.4.4 spec/rubyspec/core/array/dup_spec.rb
opal-0.4.3 spec/rubyspec/core/array/dup_spec.rb
opal-0.4.2 spec/rubyspec/core/array/dup_spec.rb
opal-0.4.1 spec/rubyspec/core/array/dup_spec.rb
opal-0.4.0 spec/rubyspec/core/array/dup_spec.rb
opal-0.3.44 spec/rubyspec/core/array/dup_spec.rb
opal-0.3.43 spec/rubyspec/core/array/dup_spec.rb
opal-0.3.42 spec/core/array/dup_spec.rb
opal-0.3.41 spec/core/array/dup_spec.rb
opal-0.3.40 spec/core/array/dup_spec.rb
opal-0.3.39 spec/core/array/dup_spec.rb
opal-0.3.38 spec/core/array/dup_spec.rb
opal-0.3.37 spec/core/array/dup_spec.rb
opal-0.3.36 spec/core/array/dup_spec.rb
opal-0.3.35 spec/core/array/dup_spec.rb
opal-0.3.34 spec/core/array/dup_spec.rb
opal-0.3.33 spec/core/array/dup_spec.rb
opal-0.3.32 spec/core/array/dup_spec.rb
opal-0.3.31 spec/core/array/dup_spec.rb
opal-0.3.30 spec/core/array/dup_spec.rb