2008-05-18 06:22:34 +02:00
|
|
|
require 'abstract_unit'
|
2007-12-21 08:48:59 +01:00
|
|
|
|
|
|
|
class DuplicableTest < Test::Unit::TestCase
|
2008-10-27 07:47:01 +01:00
|
|
|
NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), Class.new]
|
2007-12-21 08:48:59 +01:00
|
|
|
YES = ['1', Object.new, /foo/, [], {}, Time.now]
|
|
|
|
|
|
|
|
def test_duplicable
|
|
|
|
NO.each do |v|
|
|
|
|
assert !v.duplicable?
|
|
|
|
begin
|
|
|
|
v.dup
|
|
|
|
fail
|
|
|
|
rescue Exception
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
YES.each do |v|
|
|
|
|
assert v.duplicable?
|
|
|
|
assert_nothing_raised { v.dup }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|