diff options
author | Jean Boussier <[email protected]> | 2022-06-18 10:29:52 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2022-06-18 14:49:02 +0200 |
commit | eca31d24d606a73def3674938112dc3c5b79c445 (patch) | |
tree | aa713097baa398f55af41319f6fe1d5c2c583730 /test/ruby/test_autoload.rb | |
parent | e7117115399981e1258ca6301e76cc3a24c509e7 (diff) |
[Bug #18813] Warn when autoload has to lookup in parent namespace
This is a verbose mode only warning.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6038
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r-- | test/ruby/test_autoload.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index bd875ec008..2e1a6ef2b9 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -479,6 +479,7 @@ p Foo::Bar File.write(autoload_path, '') assert_separately(%W[-I #{tmpdir}], <<-RUBY) + $VERBOSE = nil path = #{File.realpath(autoload_path).inspect} autoload :X, path assert_equal(path, Object.autoload?(:X)) @@ -557,4 +558,20 @@ p Foo::Bar RUBY end end + + def test_autoload_parent_namespace + Dir.mktmpdir('autoload') do |tmpdir| + autoload_path = File.join(tmpdir, "some_const.rb") + File.write(autoload_path, 'class SomeConst; end') + + assert_separately(%W[-I #{tmpdir}], <<-RUBY) + module SomeNamespace + autoload :SomeConst, #{File.realpath(autoload_path).inspect} + assert_warning(%r{/some_const\.rb to define SomeNamespace::SomeConst but it didn't}) do + assert_not_nil SomeConst + end + end + RUBY + end + end end |