diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 11:42:24 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 11:42:24 +0000 |
commit | ac7f5157ac9d35b40da74ad932e9997f3f3e38a4 (patch) | |
tree | 5475ac890dc8c95f3a1033f84776bfd3ae889001 /test | |
parent | e5e5d0c55efb5f51c6825c58a95f9ad77408b1d1 (diff) | |
download | ruby-ac7f5157ac9d35b40da74ad932e9997f3f3e38a4.tar.gz |
* object.c (rb_mod_const_get): Fix constant missing exception class
and message to maintain backwards compatibility. Constant search
should start at Object when constant starts with '::'
* test/ruby/test_module.rb: test for fixes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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)) |