summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-25 05:35:17 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-25 05:35:17 +0000
commit9869b65573d5bbaf5af4f20a577b41f95d73b846 (patch)
treead5c6e0d5da33aabfe56e3831dc79315d2d41306 /test/ruby
parentad0b27d0547f97bd114880b78d1cc06230310241 (diff)
merge revision(s) 62394,62395: [Backport #14469]
vm_insnhelper.c: rb_autoloading_value flag * vm_insnhelper.c (vm_get_ev_const): add flag argument of `rb_autoloading_value`. * constant.h (rb_autoloading_value): moved the declaration from vm_core.h for `rb_const_flag_t`. [ruby-core:85516] [Bug #14469] 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/branches/ruby_2_4@62916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_autoload.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index 961825e0d0..59b90c1252 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -246,6 +246,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)}