diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-15 07:11:25 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-15 07:11:25 +0000 |
commit | bb4ebaa858c3c73888ffb4639f6854b78955f9ed (patch) | |
tree | cfa5bb228194f14cc03b9aff5f830fd5b82abfc7 /activesupport/test/core_ext | |
parent | fe234a1538dd96c6e0d3ca44b651fcc7abc4663e (diff) | |
download | rails-bb4ebaa858c3c73888ffb4639f6854b78955f9ed.tar.gz rails-bb4ebaa858c3c73888ffb4639f6854b78955f9ed.tar.bz2 rails-bb4ebaa858c3c73888ffb4639f6854b78955f9ed.zip |
object.duplicable? returns true if object.dup is safe. False for nil, true, false, symbols, and numbers; true otherwise. References #9333.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7906 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/duplicable_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/duplicable_test.rb b/activesupport/test/core_ext/duplicable_test.rb new file mode 100644 index 0000000000..7f8c0f7d3b --- /dev/null +++ b/activesupport/test/core_ext/duplicable_test.rb @@ -0,0 +1,22 @@ +require File.dirname(__FILE__) + '/../abstract_unit' + +class DuplicableTest < Test::Unit::TestCase + NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56')] + YES = ['1', Object.new, /foo/, [], {}] + + 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 |