diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-06 13:56:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-06 13:56:58 +0000 |
commit | 7387c08373a9421356da2581b1035903ac0a301a (patch) | |
tree | a4e3baed84a314430ecdb21402c3081404edaadd /test | |
parent | 5e7167f8fb954ec46eb12a4a0a1191a8f7d9543d (diff) | |
download | ruby-7387c08373a9421356da2581b1035903ac0a301a.tar.gz |
const_missing on private constants
* variable.c (rb_const_search): call #const_missing method on
private constants, as well as uninitialized constants.
[Feature #14328]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_module.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 78b285157f..08254605cf 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1422,6 +1422,21 @@ class TestModule < Test::Unit::TestCase RUBY end + def test_private_constant_const_missing + c = Class.new + c.const_set(:FOO, "foo") + c.private_constant(:FOO) + class << c + attr_reader :const_missing_arg + def const_missing(name) + @const_missing_arg = name + name == :FOO ? const_get(:FOO) : super + end + end + assert_equal("foo", c::FOO) + assert_equal(:FOO, c.const_missing_arg) + end + class PrivateClass end private_constant :PrivateClass |