aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_module.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-16 11:39:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-16 11:39:29 +0000
commit702c13edd7bcbf17007f4367f6c086f468c22313 (patch)
tree7e698353405aa97ded76ebe1dd4ebc24d5cedfb5 /test/ruby/test_module.rb
parent857449b06e365fd5bde74f02fc1ad8892f44b882 (diff)
downloadruby-702c13edd7bcbf17007f4367f6c086f468c22313.tar.gz
variable.c: fail if frozen
* variable.c (set_const_visibility): fail if the class/module is frozen. [ruby-core:70828] [Bug #11532] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r--test/ruby/test_module.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 18db88f04a..e04152f845 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1948,6 +1948,25 @@ class TestModule < Test::Unit::TestCase
end
end
+ def test_frozen_visibility
+ bug11532 = '[ruby-core:70828] [Bug #11532]'
+
+ c = Class.new {const_set(:A, 1)}.freeze
+ assert_raise_with_message(RuntimeError, /frozen class/, bug11532) {
+ c.class_eval {private_constant :A}
+ }
+
+ c = Class.new {const_set(:A, 1); private_constant :A}.freeze
+ assert_raise_with_message(RuntimeError, /frozen class/, bug11532) {
+ c.class_eval {public_constant :A}
+ }
+
+ c = Class.new {const_set(:A, 1)}.freeze
+ assert_raise_with_message(RuntimeError, /frozen class/, bug11532) {
+ c.class_eval {deprecate_constant :A}
+ }
+ end
+
def test_singleton_class_ancestors
feature8035 = '[ruby-core:53171]'
obj = Object.new