diff options
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r-- | test/ruby/test_module.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 774139b9bc..6cdd832e4d 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -240,6 +240,24 @@ class TestModule < Test::Unit::TestCase assert(!Math.const_defined?("IP")) end + def test_bad_constants + [ + "#<Class:0x7b8b718b>", + ":Object", + "", + ":", + ].each do |name| + e = assert_raises(NameError) { + Object.const_get name + } + assert_equal("wrong constant name %s" % name, e.message) + end + end + + def test_leading_colons + assert_equal Object, AClass.const_get('::Object') + end + def test_const_get assert_equal(Math::PI, Math.const_get("PI")) assert_equal(Math::PI, Math.const_get(:PI)) |