mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/rdoc] Fix chained inclusion ancestors_of
Fixes #814
Signed-off-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>
b45f747216
This commit is contained in:
parent
c7d1989986
commit
ec9a9af375
2 changed files with 28 additions and 4 deletions
|
@ -616,11 +616,11 @@ or the PAGER environment variable.
|
||||||
|
|
||||||
stores = classes[current]
|
stores = classes[current]
|
||||||
|
|
||||||
break unless stores and not stores.empty?
|
next unless stores and not stores.empty?
|
||||||
|
|
||||||
klasses = stores.map do |store|
|
klasses = stores.flat_map do |store|
|
||||||
store.ancestors[current]
|
store.ancestors[current] || []
|
||||||
end.flatten.uniq
|
end.uniq
|
||||||
|
|
||||||
klasses = klasses - seen
|
klasses = klasses - seen
|
||||||
|
|
||||||
|
|
|
@ -421,6 +421,30 @@ class TestRDocRIDriver < RDoc::TestCase
|
||||||
assert_equal %w[X Mixin Object Foo], @driver.ancestors_of('Foo::Bar')
|
assert_equal %w[X Mixin Object Foo], @driver.ancestors_of('Foo::Bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ancestors_of_chained_inclusion
|
||||||
|
# Store represents something like:
|
||||||
|
#
|
||||||
|
# module X
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# module Y
|
||||||
|
# include X
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# class Z
|
||||||
|
# include Y
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# Y is not chosen randomly, it has to be after Object in the alphabet
|
||||||
|
# to reproduce https://github.com/ruby/rdoc/issues/814.
|
||||||
|
store = RDoc::RI::Store.new @home_ri
|
||||||
|
store.cache[:ancestors] = { "Z" => ["Object", "Y"], "Y" => ["X"] }
|
||||||
|
store.cache[:modules] = %W[X Y Z]
|
||||||
|
@driver.stores = [store]
|
||||||
|
|
||||||
|
assert_equal %w[X Y Object], @driver.ancestors_of('Z')
|
||||||
|
end
|
||||||
|
|
||||||
def test_classes
|
def test_classes
|
||||||
util_multi_store
|
util_multi_store
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue