/vendor/gems/facets-2.4.5/test/more/test_cloneable.rb
Ruby | 41 lines | 35 code | 6 blank | 0 comment | 0 complexity | 204365375d5c62883769db75ff417e85 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
- 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