Sha256: 3dd55af745021aa9535eb885663eab24268b76c4f612609b9427f92d61e99a5b

Contents?: true

Size: 664 Bytes

Versions: 17

Compression:

Stored size: 664 Bytes

Contents

require 'facets/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

17 entries across 17 versions & 1 rubygems

Version Path
facets-2.8.4 test/more/test_cloneable.rb
facets-2.8.3 test/more/test_cloneable.rb
facets-2.8.2 test/more/test_cloneable.rb
facets-2.8.1 test/more/test_cloneable.rb
facets-2.8.0 test/more/test_cloneable.rb
facets-2.7.0 test/more/test_cloneable.rb
facets-2.6.0 test/more/test_cloneable.rb
facets-2.4.0 test/test_cloneable.rb
facets-2.3.0 test/mixin/test_cloneable.rb
facets-2.4.1 test/test_cloneable.rb
facets-2.4.4 test/more/test_cloneable.rb
facets-2.4.2 test/more/test_cloneable.rb
facets-2.4.3 test/more/test_cloneable.rb
facets-2.4.5 test/more/test_cloneable.rb
facets-2.5.0 test/more/test_cloneable.rb
facets-2.5.1 test/more/test_cloneable.rb
facets-2.5.2 test/more/test_cloneable.rb