Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicable test is looking fine now. #1186

Merged
merged 1 commit into from Jul 24, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions activesupport/test/core_ext/duplicable_test.rb
Expand Up @@ -4,22 +4,27 @@
require 'active_support/core_ext/numeric/time' require 'active_support/core_ext/numeric/time'


class DuplicableTest < Test::Unit::TestCase class DuplicableTest < Test::Unit::TestCase
NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), Class.new, Module.new, 5.seconds] RAISE_DUP = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), 5.seconds]
YES = ['1', Object.new, /foo/, [], {}, Time.now] YES = ['1', Object.new, /foo/, [], {}, Time.now]
NO = [Class.new, Module.new]


def test_duplicable def test_duplicable
NO.each do |v| (RAISE_DUP + NO).each do |v|
assert !v.duplicable? assert !v.duplicable?
begin
v.dup
fail
rescue Exception
end
end end


YES.each do |v| YES.each do |v|
assert v.duplicable? assert v.duplicable?
end

(YES + NO).each do |v|
assert_nothing_raised { v.dup } assert_nothing_raised { v.dup }
end end

RAISE_DUP.each do |v|
assert_raises(TypeError) do
v.dup
end
end
end end
end end