summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-11 16:12:29 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-11 16:12:29 +0000
commitb9ae7528dd0fc3b69cedc37a390e7d82accddeda (patch)
tree5fef05be76d79777ec2924f4738a72eb60dd447c /test
parent2e081760e3007505ac821869a15ca2922b88b4f9 (diff)
merge revision(s) 50515: [Backport #11155]
* 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/branches/ruby_2_2@50835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_autoload.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index a95c27451b..da8855b2cc 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_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'