diff options
Diffstat (limited to 'test/ruby/test_defined.rb')
-rw-r--r-- | test/ruby/test_defined.rb | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index de64ac46f8..bae85c9265 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -86,34 +86,39 @@ class TestDefined < Test::Unit::TestCase assert_equal nil, defined?($2) end + class TestAutoloadedSuperclass + autoload :A, "a" + end + + class TestAutoloadedSubclass < TestAutoloadedSuperclass + def a? + defined?(A) + end + end + def test_autoloaded_subclass bug = "[ruby-core:35509]" - klass = Class.new do - autoload(:A, "a") - end - x = klass.new + x = TestAutoloadedSuperclass.new class << x def a?; defined?(A); end end assert_equal("constant", x.a?, bug) - klass = Class.new(klass) do - def a?; defined?(A); end + assert_equal("constant", TestAutoloadedSubclass.new.a?, bug) + end + + class TestAutoloadedNoload + autoload :A, "a" + def a? + defined?(A) end - assert_equal("constant", klass.new.a?, bug) end def test_autoloaded_noload loaded = $".dup $".clear - klass = Class.new do - autoload(:A, "a") - def a? - defined?(A) - end - end - x = klass.new + x = TestAutoloadedNoload.new assert_equal("constant", x.a?) assert_equal([], $") ensure |