summaryrefslogtreecommitdiff
path: root/test/ruby/test_require.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-31 01:14:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-31 01:14:51 +0000
commit58508e8b558e1ae83d2f15617cb09f1cee8e222e (patch)
treedc30aa5c4d801c486503fd4a617f10307f4aa02f /test/ruby/test_require.rb
parentc5e8627f658c88b2403e7b20637cf25e31feff88 (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/ruby/test_require.rb')
-rw-r--r--test/ruby/test_require.rb20
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