summaryrefslogtreecommitdiff
path: root/bootstraptest/test_autoload.rb
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-10 06:32:06 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-10 06:32:06 +0000
commit564fb6a795b8a9692664f3c541d5aec4fd1f69c7 (patch)
tree9fb82987be69d619ca6747f2ac3cd2fff94cd69f /bootstraptest/test_autoload.rb
parent8c812c9a03027617b3681205544a26f297d4d641 (diff)
* 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
Diffstat (limited to 'bootstraptest/test_autoload.rb')
-rw-r--r--bootstraptest/test_autoload.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/bootstraptest/test_autoload.rb b/bootstraptest/test_autoload.rb
index b781fdb..e8df668 100644
--- a/bootstraptest/test_autoload.rb
+++ b/bootstraptest/test_autoload.rb
@@ -1,4 +1,36 @@
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"
ZZZ.ok