From bb54d0ae4cafaecfecb2299d7acacaa642afce5c Mon Sep 17 00:00:00 2001 From: shugo Date: Fri, 11 Jan 2013 00:58:08 +0000 Subject: * insns.def (defineclass): private constants should not be accessed by scoped module definitions. The bug was introduced in r38495. * test/ruby/test_module.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_module.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 340c37762a..6e25dac1d5 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1604,6 +1604,26 @@ class TestModule < Test::Unit::TestCase assert_top_method_is_private(:define_method) end + module PrivateConstantReopen + PRIVATE_CONSTANT = true + private_constant :PRIVATE_CONSTANT + end + + def test_private_constant_reopen + assert_raise(NameError) do + eval <<-EOS, TOPLEVEL_BINDING + module TestModule::PrivateConstantReopen::PRIVATE_CONSTANT + end + EOS + end + assert_raise(NameError) do + eval <<-EOS, TOPLEVEL_BINDING + class TestModule::PrivateConstantReopen::PRIVATE_CONSTANT + end + EOS + end + end + private def assert_top_method_is_private(method) -- cgit v1.2.3