aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/test/core_ext/duplicable_test.rb
blob: 24e0ccd9b364645b50b942e82f3a0a23738a3f92 (plain) (tree)
1
2
3
4
5
6
7
8
                       

                                                   
                                              

                                           
                                                                                                     
                                                  
















                                     
require 'abstract_unit'
require 'bigdecimal'
require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/numeric/time'

class DuplicableTest < Test::Unit::TestCase
  NO  = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), Class.new, Module.new, 5.seconds]
  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