summaryrefslogtreecommitdiff
path: root/test/ruby/test_autoload.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-27 02:19:42 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-27 02:19:42 +0000
commit4d033a11c5bd778f124febb30e419bd91d372076 (patch)
tree541ad7a4885c81d12badfc717ed29a09cc41e9c2 /test/ruby/test_autoload.rb
parent80d6bf2291380b5860b2fa588404d7721bf34c30 (diff)
* Revert r33078. It caused a Rails application NoMethodError.
/home/nahi/git/emptyApp/ruby/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/utils.rb:157: warning: toplevel constant ScanError referenced by Regin::Parser::ScanError /home/nahi/git/emptyApp/ruby/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/vendor/regin/regin/parser.rb:17:in `parse_regexp': undefined method `scan_str' for #<Regin::Parser:0x00000002344548> (NoMethodError) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r--test/ruby/test_autoload.rb110
1 files changed, 0 insertions, 110 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index a3a4c5df1a..e175e57006 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -1,6 +1,4 @@
require 'test/unit'
-require 'tempfile'
-require 'thread'
require_relative 'envutil'
class TestAutoload < Test::Unit::TestCase
@@ -55,112 +53,4 @@ p Foo::Bar
assert_equal(tmpfile, b.autoload?(:X), bug4565)
}
end
-
- def test_require_explicit
- file = Tempfile.open(['autoload', '.rb'])
- file.puts 'class Object; AutoloadTest = 1; end'
- file.close
- add_autoload(file.path)
- begin
- assert_nothing_raised do
- assert(require file.path)
- assert_equal(1, ::AutoloadTest)
- end
- ensure
- remove_autoload_constant
- end
- end
-
- def test_threaded_accessing_constant
- file = Tempfile.open(['autoload', '.rb'])
- file.puts 'sleep 0.5; class AutoloadTest; X = 1; end'
- file.close
- add_autoload(file.path)
- begin
- assert_nothing_raised do
- t1 = Thread.new { ::AutoloadTest::X }
- t2 = Thread.new { ::AutoloadTest::X }
- [t1, t2].each(&:join)
- end
- ensure
- remove_autoload_constant
- end
- end
-
- def test_threaded_accessing_inner_constant
- file = Tempfile.open(['autoload', '.rb'])
- file.puts 'class AutoloadTest; sleep 0.5; X = 1; end'
- file.close
- add_autoload(file.path)
- begin
- assert_nothing_raised do
- t1 = Thread.new { ::AutoloadTest::X }
- t2 = Thread.new { ::AutoloadTest::X }
- [t1, t2].each(&:join)
- end
- ensure
- remove_autoload_constant
- end
- end
-
- def test_nameerror_when_autoload_did_not_define_the_constant
- file = Tempfile.open(['autoload', '.rb'])
- file.puts ''
- file.close
- add_autoload(file.path)
- begin
- assert_raise(NameError) do
- AutoloadTest
- end
- ensure
- remove_autoload_constant
- end
- end
-
- def test_override_autoload
- file = Tempfile.open(['autoload', '.rb'])
- file.puts ''
- file.close
- add_autoload(file.path)
- begin
- eval %q(class AutoloadTest; end)
- assert_equal(Class, AutoloadTest.class)
- ensure
- remove_autoload_constant
- end
- end
-
- def test_override_while_autoloading
- file = Tempfile.open(['autoload', '.rb'])
- file.puts 'class AutoloadTest; sleep 0.5; end'
- file.close
- add_autoload(file.path)
- begin
- # while autoloading...
- t = Thread.new { AutoloadTest }
- sleep 0.1
- # override it
- eval %q(AutoloadTest = 1)
- t.join
- assert_equal(1, AutoloadTest)
- ensure
- remove_autoload_constant
- end
- end
-
- def add_autoload(path)
- eval <<-END
- class ::Object
- autoload :AutoloadTest, #{path.dump}
- end
- END
- end
-
- def remove_autoload_constant
- eval <<-END
- class ::Object
- remove_const(:AutoloadTest)
- end
- END
- end
end