2011-09-22 15:17:42 -04:00
|
|
|
module Ace
|
|
|
|
module Base
|
|
|
|
class Case
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module ConstantizeTestCases
|
|
|
|
def run_constantize_tests_on
|
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Case, yield("Ace::Base::Case") }
|
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Case, yield("::Ace::Base::Case") }
|
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") }
|
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") }
|
|
|
|
assert_raise(NameError) { yield("UnknownClass") }
|
2011-09-23 10:16:53 -04:00
|
|
|
assert_raise(NameError) { yield("UnknownClass::Ace") }
|
|
|
|
assert_raise(NameError) { yield("UnknownClass::Ace::Base") }
|
2011-09-22 15:17:42 -04:00
|
|
|
assert_raise(NameError) { yield("An invalid string") }
|
|
|
|
assert_raise(NameError) { yield("InvalidClass\n") }
|
2011-09-23 10:16:53 -04:00
|
|
|
assert_raise(NameError) { yield("Ace::ConstantizeTestCases") }
|
2011-09-22 15:17:42 -04:00
|
|
|
assert_raise(NameError) { yield("Ace::Base::ConstantizeTestCases") }
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_safe_constantize_tests_on
|
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Case, yield("Ace::Base::Case") }
|
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Case, yield("::Ace::Base::Case") }
|
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") }
|
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") }
|
|
|
|
assert_nothing_raised { assert_equal nil, yield("UnknownClass") }
|
2011-09-23 10:16:53 -04:00
|
|
|
assert_nothing_raised { assert_equal nil, yield("UnknownClass::Ace") }
|
|
|
|
assert_nothing_raised { assert_equal nil, yield("UnknownClass::Ace::Base") }
|
2011-09-22 15:17:42 -04:00
|
|
|
assert_nothing_raised { assert_equal nil, yield("An invalid string") }
|
|
|
|
assert_nothing_raised { assert_equal nil, yield("InvalidClass\n") }
|
|
|
|
assert_nothing_raised { assert_equal nil, yield("blargle") }
|
2011-09-23 10:16:53 -04:00
|
|
|
assert_nothing_raised { assert_equal nil, yield("Ace::ConstantizeTestCases") }
|
2011-09-22 15:17:42 -04:00
|
|
|
assert_nothing_raised { assert_equal nil, yield("Ace::Base::ConstantizeTestCases") }
|
|
|
|
end
|
|
|
|
end
|