Created
May 16, 2015 18:31
-
-
Save tenderlove/f17b53b38675f0086dfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/load.c b/load.c | |
index 39315df..4ea5280 100644 | |
--- a/load.c | |
+++ b/load.c | |
@@ -317,7 +317,7 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len, | |
const char *e; | |
if (vlen < len+1) return 0; | |
- if (!strncmp(name+(vlen-len), feature, len)) { | |
+ if (!strncmp(name+(vlen-len), feature, len) && strchr(feature, '.')) { | |
plen = vlen - len; | |
} | |
else { | |
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb | |
index 5b1bbc0..30ac897 100644 | |
--- a/test/ruby/test_autoload.rb | |
+++ b/test/ruby/test_autoload.rb | |
@@ -55,6 +55,32 @@ p Foo::Bar | |
} | |
end | |
+ def test_autoload_with_relative_name | |
+ lp = $LOAD_PATH.dup | |
+ lf = $LOADED_FEATURES.dup | |
+ | |
+ Dir.mktmpdir('autoload') { |tmpdir| | |
+ $LOAD_PATH << tmpdir | |
+ | |
+ Dir.chdir(tmpdir) do | |
+ eval <<-END | |
+ class ::Object | |
+ module A | |
+ autoload :C, 'b' | |
+ end | |
+ end | |
+ END | |
+ | |
+ File.open('b.rb', 'w') {|file| file.puts 'module A; class C; end; end'} | |
+ assert_kind_of Class, ::A::C | |
+ end | |
+ } | |
+ ensure | |
+ $LOAD_PATH.replace lp | |
+ $LOADED_FEATURES.replace lf | |
+ Object.send(:remove_const, :A) if Object.const_defined?(:A) | |
+ end | |
+ | |
def test_require_explicit | |
Tempfile.create(['autoload', '.rb']) {|file| | |
file.puts 'class Object; AutoloadTest = 1; end' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment