diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-13 09:36:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-13 09:36:35 +0000 |
commit | 248ff4f1b19409f92bad9749d1ce202b7c81a754 (patch) | |
tree | 1d1d082ee07075593c11015f30a0371fd19e2eaa /test/ruby/test_autoload.rb | |
parent | 8cdac548c54ad3a1df70da47ad820f3afc96e2cb (diff) |
variable.c: flags at autoloading
* variable.c (const_tbl_update): flags by deprecate_constant /
private_constant set during autoloading should be preserved
after required. [ruby-core:85516] [Bug #14469]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r-- | test/ruby/test_autoload.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 9d16a45e23..0220f3e27d 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -245,6 +245,46 @@ p Foo::Bar assert_ruby_status([script], '', '[ruby-core:81016] [Bug #13526]') end + def test_autoload_private_constant + Dir.mktmpdir('autoload') do |tmpdir| + File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class AutoloadTest + ZZZ = :ZZZ + private_constant :ZZZ + end + end; + assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}") + bug = '[ruby-core:85516] [Bug #14469]' + begin; + class AutoloadTest + autoload :ZZZ, "zzz.rb" + end + assert_raise(NameError, bug) {AutoloadTest::ZZZ} + end; + end + end + + def test_autoload_deprecate_constant + Dir.mktmpdir('autoload') do |tmpdir| + File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class AutoloadTest + ZZZ = :ZZZ + deprecate_constant :ZZZ + end + end; + assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}") + bug = '[ruby-core:85516] [Bug #14469]' + begin; + class AutoloadTest + autoload :ZZZ, "zzz.rb" + end + assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ} + end; + end + end + def add_autoload(path) (@autoload_paths ||= []) << path ::Object.class_eval {autoload(:AutoloadTest, path)} |