variable.c: Module#deprecate_constant

* variable.c (rb_const_get_0): warn deprecated constant reference.
* variable.c (rb_mod_deprecate_constant): mark constants to be
  warned as deprecated.  [Feature #11398]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-07-30 04:20:00 +00:00
parent c3f6e4ea07
commit 83cd51e3fe
7 changed files with 51 additions and 6 deletions

View file

@ -1360,6 +1360,13 @@ class TestModule < Test::Unit::TestCase
assert_equal("foo", c::FOO)
end
def test_deprecate_constant
c = Class.new
c.const_set(:FOO, "foo")
c.deprecate_constant(:FOO)
assert_warn(/deprecated/) {c::FOO}
end
def test_constants_with_private_constant
assert_not_include(::TestModule.constants, :PrivateClass)
end