summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-05-07 12:52:24 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-21 17:28:37 +0900
commitfb85a428605265a8fd449b0702a4dd88cb6f3b20 (patch)
tree0e5f9df92b010b026cfab40a54a1778f55f93e61 /spec
parent887163beb8f27c5400cd04dbf98c474ed035526f (diff)
Add an optional `inherit` argument to Module#autoload?
[Feature #15777] Closes: https://github.com/ruby/ruby/pull/2173
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/module/autoload_spec.rb12
-rw-r--r--spec/ruby/core/module/fixtures/classes.rb6
2 files changed, 18 insertions, 0 deletions
diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb
index eaad4b8df6..09fbafd51c 100644
--- a/spec/ruby/core/module/autoload_spec.rb
+++ b/spec/ruby/core/module/autoload_spec.rb
@@ -11,6 +11,18 @@ describe "Module#autoload?" do
it "returns nil if no file has been registered for a constant" do
ModuleSpecs::Autoload.autoload?(:Manualload).should be_nil
end
+
+ it "returns the name of the file that will be autoloaded if an ancestor defined that autoload" do
+ ModuleSpecs::Autoload::Parent.autoload :AnotherAutoload, "another_autoload.rb"
+ ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload).should == "another_autoload.rb"
+ end
+
+ ruby_version_is "2.7" do
+ it "returns nil if an ancestor defined that autoload but recursion is disabled" do
+ ModuleSpecs::Autoload::Parent.autoload :AnotherAutoload, "another_autoload.rb"
+ ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload, false).should be_nil
+ end
+ end
end
describe "Module#autoload" do
diff --git a/spec/ruby/core/module/fixtures/classes.rb b/spec/ruby/core/module/fixtures/classes.rb
index f93c39683e..ef70eaf9cf 100644
--- a/spec/ruby/core/module/fixtures/classes.rb
+++ b/spec/ruby/core/module/fixtures/classes.rb
@@ -386,6 +386,12 @@ module ModuleSpecs
end
end
+ class Parent
+ end
+
+ class Child < Parent
+ end
+
module FromThread
module A
autoload :B, fixture(__FILE__, "autoload_empty.rb")