ruby-changes:19521
From: drbrain <ko1@a...>
Date: Sat, 14 May 2011 12:10:38 +0900 (JST)
Subject: [ruby-changes:19521] drbrain:r31561 (trunk): * lib/rdoc/context.rb (class RDoc): Fix infinite loop caused by
drbrain 2011-05-14 12:07:38 +0900 (Sat, 14 May 2011) New Revision: 31561 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31561 Log: * lib/rdoc/context.rb (class RDoc): Fix infinite loop caused by re-encountering BasicObject. Modified files: trunk/ChangeLog trunk/lib/rdoc/context.rb trunk/test/rdoc/test_rdoc_context.rb trunk/test/rdoc/test_rdoc_ri_store.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31560) +++ ChangeLog (revision 31561) @@ -1,3 +1,8 @@ +Sat May 14 12:06:49 2011 Eric Hodel <drbrain@s...> + + * lib/rdoc/context.rb (class RDoc): Fix infinite loop caused by + re-encountering BasicObject. + Sat May 14 10:32:36 2011 Martin Bosslet <Martin.Bosslet@g...> * test/openssl/test_pkey_rsa.rb: Add tests that ensure new public key Index: lib/rdoc/context.rb =================================================================== --- lib/rdoc/context.rb (revision 31560) +++ lib/rdoc/context.rb (revision 31561) @@ -373,6 +373,12 @@ end end + # fix up superclass + superclass = nil if full_name == 'BasicObject' + superclass = nil if full_name == 'Object' and defined?(::BasicObject) + superclass = '::BasicObject' if + defined?(::BasicObject) and full_name == 'Object' + # find the superclass full name if superclass then if superclass =~ /^:+/ then @@ -658,6 +664,13 @@ end ## + # Iterator for ancestors for duck-typing. Does nothing. See + # RDoc::ClassModule#each_ancestor. + + def each_ancestor # :nodoc: + end + + ## # Iterator for attributes def each_attribute # :yields: attribute Index: test/rdoc/test_rdoc_context.rb =================================================================== --- test/rdoc/test_rdoc_context.rb (revision 31560) +++ test/rdoc/test_rdoc_context.rb (revision 31561) @@ -105,6 +105,38 @@ assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass' end + def test_add_class_basic_object + skip 'BasicObject is 1.9 only' unless defined?(BasicObject) + + @xref_data.add_class RDoc::NormalClass, 'BasicObject' + + basic = @xref_data.find_module_named 'BasicObject' + + assert_nil basic.superclass + + @c1.add_class RDoc::NormalClass, 'BasicObject' + + basic = @c1.find_module_named 'BasicObject' + + assert_equal 'Object', basic.superclass + end + + def test_add_class_object + root_class = defined?(BasicObject) ? 'BasicObject' : nil + + @xref_data.add_class RDoc::NormalClass, 'Object' + + object = @xref_data.find_module_named 'Object' + + assert_equal root_class, object.superclass + + @c1.add_class RDoc::NormalClass, 'Object' + + object = @c1.find_module_named 'Object' + + assert_equal 'Object', object.superclass.full_name + end + def test_add_class_superclass @c1.add_class RDoc::NormalClass, 'Klass', 'Object' @c1.add_class RDoc::NormalClass, 'Klass', 'Other' Index: test/rdoc/test_rdoc_ri_store.rb =================================================================== --- test/rdoc/test_rdoc_ri_store.rb (revision 31560) +++ test/rdoc/test_rdoc_ri_store.rb (revision 31561) @@ -215,6 +215,8 @@ }, } + expected[:ancestors]['Object'] = %w[BasicObject] if defined?(::BasicObject) + open File.join(@tmpdir, 'cache.ri'), 'rb' do |io| cache = Marshal.load io.read @@ -250,8 +252,10 @@ assert_directory File.join(@tmpdir, 'Object') assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri') + object_ancestors = defined?(::BasicObject) ? %w[BasicObject] : [] + assert_cache({}, {}, { 'Object' => ['attr_accessor attr'] }, %w[Object], - 'Object' => %w[]) + 'Object' => object_ancestors) assert_equal @klass, @s.load_class('Object') end @@ -303,8 +307,10 @@ assert_directory File.join(@tmpdir, 'Object') assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri') + object_ancestors = defined?(::BasicObject) ? %w[BasicObject] : [] + assert_cache({}, {}, { 'Object' => ['attr_accessor attr'] }, %w[Object], - 'Object' => %w[]) + 'Object' => object_ancestors) assert_equal @klass, @s.load_class('Object') end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/