From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31078 217.115.0.0/20 X-Spam-Status: No, score=-1.5 required=3.0 tests=BAYES_00,RCVD_IN_XBL shortcircuit=no autolearn=no version=3.3.2 X-Original-To: spew@80x24.org Received: from 80x24.org (tor31.anonymizer.ccc.de [217.115.10.131]) by dcvr.yhbt.net (Postfix) with ESMTP id 9BD031F4A7 for ; Thu, 5 Nov 2015 22:07:53 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] test_autoload: WIP nested autoload test Date: Thu, 5 Nov 2015 22:07:51 +0000 Message-Id: <20151105220751.24371-1-e@80x24.org> List-Id: --- 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