mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
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
This commit is contained in:
parent
c3a48736a6
commit
dfa9eb54bd
3 changed files with 25 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue