Sha256: 566b6e1e697f08cbaa90382add8e1a92cddeeb3d93557214a7a45b3f3933ff26

Contents?: true

Size: 664 Bytes

Versions: 3

Compression:

Stored size: 664 Bytes

Contents

require 'mixers/cloneable'
require 'test/unit'

class Foo
  include Cloneable
  def initialize
    @bar=[]
  end
  def bar_id
    @bar.object_id
  end
end

class TestCloneable < Test::Unit::TestCase
  def test_dup
    a=Foo.new
    b=a.dup
    assert_not_equal a.bar_id,b.bar_id

    a.taint
    b=a.dup
    assert b.tainted?, "b should be tainted"

    a.freeze
    b=a.dup
    assert !b.frozen?, "b should not be frozen"
  end
  def test_clone
    a=Foo.new
    b=a.clone
    assert_not_equal a.bar_id,b.bar_id

    a.taint
    b=a.dup
    assert b.tainted?, "b should be tainted"

    a.freeze
    b=a.clone
    assert b.frozen?, "b should be frozen"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mixers-1.2.0 test/test_cloneable.rb
mixers-1.1.0 test/test_cloneable.rb
mixers-1.0.0 test/test_cloneable.rb