1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* load.c (loaded_feature_path): stop returning false negatives for

filenames which are trailing substrings of file extensions.  For
  example, 'b', which a trailing substring of ".rb" should not return
  false. [Bug #11155][ruby-core:69206]

* test/ruby/test_autoload.rb: test for fix

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2015-05-16 19:02:38 +00:00
parent fc7711ff17
commit 1fc214c04d
3 changed files with 36 additions and 1 deletions

View file

@ -55,6 +55,32 @@ p Foo::Bar
}
end
def test_autoload_with_unqualified_file_name # [ruby-core:69206]
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'