2008-01-05 13:31:04 +00:00
|
|
|
require 'abstract_unit'
|
2009-04-23 00:41:28 +00:00
|
|
|
require 'bigdecimal'
|
|
|
|
require 'active_support/core_ext/object/duplicable'
|
2007-10-15 07:11:25 +00:00
|
|
|
|
|
|
|
class DuplicableTest < Test::Unit::TestCase
|
2008-08-21 17:23:18 +00:00
|
|
|
NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), Class.new]
|
2007-10-15 07:12:40 +00:00
|
|
|
YES = ['1', Object.new, /foo/, [], {}, Time.now]
|
2007-10-15 07:11:25 +00:00
|
|
|
|
|
|
|
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
|