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
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal Ace::Base::Case, yield("Ace::Base::Case")
|
|
|
|
assert_equal Ace::Base::Case, yield("::Ace::Base::Case")
|
|
|
|
assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice")
|
2014-06-07 14:28:38 -04:00
|
|
|
assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Fase::Dice")
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice")
|
2014-06-07 14:28:38 -04:00
|
|
|
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal Ace::Gas::Case, yield("Ace::Gas::Case")
|
|
|
|
assert_equal Ace::Gas::Case::Dice, yield("Ace::Gas::Case::Dice")
|
2014-06-07 14:28:38 -04:00
|
|
|
assert_equal Ace::Base::Case::Dice, yield("Ace::Gas::Case::Dice")
|
|
|
|
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal Case::Dice, yield("Case::Dice")
|
2014-06-07 14:28:38 -04:00
|
|
|
assert_equal AddtlGlobalConstants::Case::Dice, yield("Case::Dice")
|
|
|
|
assert_equal Object::AddtlGlobalConstants::Case::Dice, yield("Case::Dice")
|
|
|
|
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal Case::Dice, yield("Object::Case::Dice")
|
2014-06-07 14:28:38 -04:00
|
|
|
assert_equal AddtlGlobalConstants::Case::Dice, yield("Object::Case::Dice")
|
|
|
|
assert_equal Object::AddtlGlobalConstants::Case::Dice, yield("Case::Dice")
|
|
|
|
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal ConstantizeTestCases, yield("ConstantizeTestCases")
|
|
|
|
assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases")
|
2014-06-07 14:28:38 -04:00
|
|
|
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_raises(NameError) { yield("UnknownClass") }
|
|
|
|
assert_raises(NameError) { yield("UnknownClass::Ace") }
|
|
|
|
assert_raises(NameError) { yield("UnknownClass::Ace::Base") }
|
|
|
|
assert_raises(NameError) { yield("An invalid string") }
|
|
|
|
assert_raises(NameError) { yield("InvalidClass\n") }
|
|
|
|
assert_raises(NameError) { yield("Ace::ConstantizeTestCases") }
|
|
|
|
assert_raises(NameError) { yield("Ace::Base::ConstantizeTestCases") }
|
|
|
|
assert_raises(NameError) { yield("Ace::Gas::Base") }
|
|
|
|
assert_raises(NameError) { yield("Ace::Gas::ConstantizeTestCases") }
|
2013-06-13 09:33:26 -04:00
|
|
|
assert_raises(NameError) { yield("") }
|
|
|
|
assert_raises(NameError) { yield("::") }
|
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
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_equal Ace::Base::Case, yield("Ace::Base::Case")
|
|
|
|
assert_equal Ace::Base::Case, yield("::Ace::Base::Case")
|
|
|
|
assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice")
|
|
|
|
assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice")
|
|
|
|
assert_equal Ace::Gas::Case, yield("Ace::Gas::Case")
|
|
|
|
assert_equal Ace::Gas::Case::Dice, yield("Ace::Gas::Case::Dice")
|
|
|
|
assert_equal Case::Dice, yield("Case::Dice")
|
|
|
|
assert_equal Case::Dice, yield("Object::Case::Dice")
|
|
|
|
assert_equal ConstantizeTestCases, yield("ConstantizeTestCases")
|
|
|
|
assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases")
|
2013-06-13 09:33:26 -04:00
|
|
|
assert_nil yield("")
|
|
|
|
assert_nil yield("::")
|
2012-11-05 22:20:56 -05:00
|
|
|
assert_nil yield("UnknownClass")
|
|
|
|
assert_nil yield("UnknownClass::Ace")
|
|
|
|
assert_nil yield("UnknownClass::Ace::Base")
|
|
|
|
assert_nil yield("An invalid string")
|
|
|
|
assert_nil yield("InvalidClass\n")
|
|
|
|
assert_nil yield("blargle")
|
|
|
|
assert_nil yield("Ace::ConstantizeTestCases")
|
|
|
|
assert_nil yield("Ace::Base::ConstantizeTestCases")
|
|
|
|
assert_nil yield("Ace::Gas::Base")
|
|
|
|
assert_nil yield("Ace::Gas::ConstantizeTestCases")
|
|
|
|
assert_nil yield("#<Class:0x7b8b718b>::Nested_1")
|
2011-09-22 15:17:42 -04:00
|
|
|
end
|
2012-01-26 14:19:49 -05:00
|
|
|
end
|