2011-09-22 15:17:42 -04:00
|
|
|
module Ace
|
|
|
|
module Base
|
|
|
|
class Case
|
2012-05-04 23:57:11 -04:00
|
|
|
class Dice
|
|
|
|
end
|
2011-09-22 15:17:42 -04:00
|
|
|
end
|
2012-05-04 23:57:11 -04:00
|
|
|
class Fase < Case
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class Gas
|
|
|
|
include Base
|
2011-09-22 15:17:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-05 10:13:33 -04:00
|
|
|
class Object
|
|
|
|
module AddtlGlobalConstants
|
|
|
|
class Case
|
|
|
|
class Dice
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
include AddtlGlobalConstants
|
|
|
|
end
|
|
|
|
|
2011-09-22 15:17:42 -04:00
|
|
|
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") }
|
2012-05-04 23:57:11 -04:00
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice") }
|
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice") }
|
|
|
|
assert_nothing_raised { assert_equal Ace::Gas::Case, yield("Ace::Gas::Case") }
|
2012-05-19 10:44:19 -04:00
|
|
|
assert_nothing_raised { assert_equal Ace::Gas::Case::Dice, yield("Ace::Gas::Case::Dice") }
|
2012-05-05 10:13:33 -04:00
|
|
|
assert_nothing_raised { assert_equal Case::Dice, yield("Case::Dice") }
|
|
|
|
assert_nothing_raised { assert_equal Case::Dice, yield("Object::Case::Dice") }
|
2011-09-22 15:17:42 -04:00
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") }
|
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") }
|
2012-05-05 10:13:33 -04:00
|
|
|
assert_nothing_raised { assert_equal Object, yield("") }
|
|
|
|
assert_nothing_raised { assert_equal Object, yield("::") }
|
2011-09-22 15:17:42 -04:00
|
|
|
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") }
|
2012-05-04 23:57:11 -04:00
|
|
|
assert_raise(NameError) { yield("Ace::Gas::Base") }
|
|
|
|
assert_raise(NameError) { yield("Ace::Gas::ConstantizeTestCases") }
|
2011-09-22 15:17:42 -04:00
|
|
|
end
|
2012-01-26 14:19:49 -05:00
|
|
|
|
2011-09-22 15:17:42 -04:00
|
|
|
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") }
|
2012-05-04 23:57:11 -04:00
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice") }
|
|
|
|
assert_nothing_raised { assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice") }
|
|
|
|
assert_nothing_raised { assert_equal Ace::Gas::Case, yield("Ace::Gas::Case") }
|
2012-05-19 10:44:19 -04:00
|
|
|
assert_nothing_raised { assert_equal Ace::Gas::Case::Dice, yield("Ace::Gas::Case::Dice") }
|
2012-05-05 10:13:33 -04:00
|
|
|
assert_nothing_raised { assert_equal Case::Dice, yield("Case::Dice") }
|
|
|
|
assert_nothing_raised { assert_equal Case::Dice, yield("Object::Case::Dice") }
|
2011-09-22 15:17:42 -04:00
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") }
|
|
|
|
assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") }
|
2012-05-05 10:13:33 -04:00
|
|
|
assert_nothing_raised { assert_equal Object, yield("") }
|
|
|
|
assert_nothing_raised { assert_equal Object, yield("::") }
|
2011-09-22 15:17:42 -04:00
|
|
|
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") }
|
2012-05-04 23:57:11 -04:00
|
|
|
assert_nothing_raised { assert_equal nil, yield("Ace::Gas::Base") }
|
|
|
|
assert_nothing_raised { assert_equal nil, yield("Ace::Gas::ConstantizeTestCases") }
|
2012-01-26 14:19:49 -05:00
|
|
|
assert_nothing_raised { assert_equal nil, yield("#<Class:0x7b8b718b>::Nested_1") }
|
2011-09-22 15:17:42 -04:00
|
|
|
end
|
2012-01-26 14:19:49 -05:00
|
|
|
end
|