aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_require.rb
diff options
context:
space:
mode:
authorNAKAMURA Usaku <usa@ruby-lang.org>2021-11-24 19:34:59 +0900
committerNAKAMURA Usaku <usa@ruby-lang.org>2021-11-24 19:34:59 +0900
commit61a02168f7ba353a2838f2783f291a816d7e0c90 (patch)
tree1990f1ef047570c97f6486d307236f7d73de5194 /test/ruby/test_require.rb
parentcd10572b059d07fe236ef9c9db9fd2a8ffc7dd38 (diff)
downloadruby-61a02168f7ba353a2838f2783f291a816d7e0c90.tar.gz
merge revision(s) ddb32e66160ab50849419ef7c7ac584913b79c34: [Backport #18173]
[Bug #18173] Update loaded_features_index If $LOADED_FEATURES is changed in the just required file, also the index table needs to be updated before loaded_features_snapshot is reset. If the snapshot is reset without updating the table, the name of the added feature will not be found. --- load.c | 1 + test/ruby/test_require.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
Diffstat (limited to 'test/ruby/test_require.rb')
-rw-r--r--test/ruby/test_require.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 4e7573b07d..a1adb4926f 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -831,6 +831,23 @@ class TestRequire < Test::Unit::TestCase
}
end
+ def test_provide_in_required_file
+ paths, loaded = $:.dup, $".dup
+ Dir.mktmpdir do |tmp|
+ provide = File.realdirpath("provide.rb", tmp)
+ File.write(File.join(tmp, "target.rb"), "raise __FILE__\n")
+ File.write(provide, '$" << '"'target.rb'\n")
+ $:.replace([tmp])
+ assert(require("provide"))
+ assert(!require("target"))
+ assert_equal($".pop, provide)
+ assert_equal($".pop, "target.rb")
+ end
+ ensure
+ $:.replace(paths)
+ $".replace(loaded)
+ end
+
if defined?($LOAD_PATH.resolve_feature_path)
def test_resolve_feature_path
paths, loaded = $:.dup, $".dup