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

* load.c (rb_f_autoload): prevent to autoload for singleton

classes.  fixes [Bug #4886] [ruby-dev:43816]
* bootstraptest/test_autoload.rb: add tests for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2011-07-10 06:32:06 +00:00
parent 8c812c9a03
commit 564fb6a795
3 changed files with 40 additions and 1 deletions

View file

@ -1,3 +1,35 @@
assert_equal 'ok', %q{
File.unlink('zzz.rb') if File.file?('zzz.rb')
instance_eval do
autoload :ZZZ, './zzz.rb'
begin
ZZZ
rescue LoadError
:ok
end
end
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
open('zzz.rb', 'w') {|f| f.puts '' }
instance_eval do
autoload :ZZZ, './zzz.rb'
begin
ZZZ
rescue NameError
:ok
end
end
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
open('zzz.rb', 'w') {|f| f.puts 'class ZZZ; def self.ok;:ok;end;end'}
instance_eval do
autoload :ZZZ, './zzz.rb'
ZZZ.ok
end
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"}
autoload :ZZZ, "./zzz.rb"