* [PATCH] test_autoload: WIP nested autoload test
@ 2015-11-05 22:07 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-11-05 22:07 UTC (permalink / raw)
To: spew
---
test/ruby/test_autoload.rb | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index 719502d..8e427e5 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -215,6 +215,37 @@ p Foo::Bar
end
end
+ def test_nested_autoload_in_ruby_require
+ ruby_impl_require do |called_with|
+ Tempfile.create(%w(a .rb)) do |a|
+ Tempfile.create(%w(b .rb)) do |b|
+ a.puts "class AutoloadTest; autoload :B, '#{b.path}'; end"
+ Tempfile.create(%w(c .rb)) do |c|
+ b.puts "class AutoloadTest; module B; autoload :C, '#{c.path}'; "\
+ "end; end"
+ c.puts "class AutoloadTest; module B; module C; end; end; end"
+
+ [ a, b, c ].each(&:flush)
+ add_autoload(a.path)
+ begin
+ thrs = []
+ 5.times do
+ thrs << Thread.new do
+ Thread.pass; Object::AutoloadTest::B::C
+ end
+ end
+ assert(Object::AutoloadTest::B::C)
+ thrs.each(&:join)
+ ensure
+ remove_autoload_constant
+ end
+ warn called_with.inspect
+ end
+ end
+ end
+ end
+ end
+
def add_autoload(path)
(@autoload_paths ||= []) << path
::Object.class_eval {autoload(:AutoloadTest, path)}
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-11-05 22:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-05 22:07 [PATCH] test_autoload: WIP nested autoload test Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).