diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 01:14:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 01:14:51 +0000 |
commit | 58508e8b558e1ae83d2f15617cb09f1cee8e222e (patch) | |
tree | dc30aa5c4d801c486503fd4a617f10307f4aa02f /test | |
parent | c5e8627f658c88b2403e7b20637cf25e31feff88 (diff) |
load.c: resolve_feature_path
* load.c (rb_resolve_feature_path): search the path for already
loaded feature.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_require.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index af8e6e30fa..a83509421d 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -897,4 +897,24 @@ class TestRequire < Test::Unit::TestCase assert_operator(result, :end_with?, "/real/a.rb") } end + + if defined?(RubyVM.resolve_feature_path) + def test_resolve_feature_path + paths, loaded = $:.dup, $".dup + Dir.mktmpdir do |tmp| + Tempfile.create(%w[feature .rb], tmp) do |file| + file.close + path = File.realpath(file.path) + dir, base = File.split(path) + $:.unshift(dir) + assert_equal([:rb, path], RubyVM.resolve_feature_path(base)) + $".push(path) + assert_equal([:rb, path], RubyVM.resolve_feature_path(base)) + end + end + ensure + $:.replace(paths) + $".replace(loaded) + end + end end |