-
Notifications
You must be signed in to change notification settings - Fork 445
Fix module recursive lookup bug #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ def test_module_extended | |
| m1_k1.add_include i1_k0_m4 | ||
|
|
||
| assert_equal [i1_m1, i1_m2, i1_m3, i1_m4, i1_k0_m4], m1_k1.includes | ||
| assert_equal [m1_m2_k0_m4, m1_m2_m3_m4, m1_m2_m3, m1_m2, m1, @object, | ||
| assert_equal [m1_m2_k0_m4, m1_m2_m4, m1_m3, m1_m2, m1, @object, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test was wrong. [Mod1::Klass1, Mod1::Mod2::Klass0::Mod4, Mod1::Mod2::Mod4, Mod1::Mod3, Mod1::Mod2, Mod1, Object, Kernel, BasicObject]module Mod1
module Mod3
end
module Mod2
module Mod3
module Mod4
end
end
module Mod4
end
class Klass0
module Mod4
# module Mod5
# end
module Mod6
end
end
module Mod5; end
include Mod4
include Mod5
include Mod6
include Mod1
include Mod2
include Mod3
end
end
class Klass1
include Mod1
include Mod2
include Mod3
include Mod4
include Klass0::Mod4
end
end
p Mod1::Klass1.ancestors
# Actual
#=> [Mod1::Klass1, Mod1::Mod2::Klass0::Mod4, Mod1::Mod2::Mod4, Mod1::Mod3, Mod1::Mod2, Mod1, Object, Kernel, BasicObject]
# Test was expecting
#=> [(omitted), Mod1::Mod2::Klass0::Mod4, Mod1::Mod2::Mod3,Mod4, Mod1::Mod2::Mod3, Mod1::Mod2, Mod1, Object, (omitted), BasicObject] |
||
| 'BasicObject'], m1_k1.ancestors | ||
|
|
||
| m1_k2 = m1.add_class RDoc::NormalClass, 'Klass2' | ||
|
|
@@ -96,6 +96,32 @@ def test_module_extended | |
| assert_equal [m1_m2_m4, m1_m2, m1, @object, 'BasicObject'], m1_k3.ancestors | ||
| end | ||
|
|
||
| def test_include_through_include | ||
| top_level = @store.add_file 'file.rb' | ||
|
|
||
| mod1 = top_level.add_module RDoc::NormalModule, 'Mod1' | ||
| mod2 = top_level.add_module RDoc::NormalModule, 'Mod2' | ||
| mod3 = top_level.add_module RDoc::NormalModule, 'Mod3' | ||
| submod = mod1.add_module RDoc::NormalModule, 'Sub' | ||
| mod2.add_include RDoc::Include.new('Mod1', '') | ||
| mod3.add_include RDoc::Include.new('Mod2', '') | ||
| mod3.add_include RDoc::Include.new('Sub', '') | ||
| assert_equal [submod, mod2], mod3.ancestors | ||
| end | ||
|
|
||
| def test_include_through_top_level_include | ||
| top_level = @store.add_file 'file.rb' | ||
|
|
||
| mod1 = top_level.add_module RDoc::NormalModule, 'Mod1' | ||
| mod2 = top_level.add_module RDoc::NormalModule, 'Mod2' | ||
| mod3 = mod2.add_module RDoc::NormalModule, 'Mod3' | ||
| submod = mod1.add_module RDoc::NormalModule, 'Sub' | ||
| mod2.add_include RDoc::Include.new('Mod1', '') | ||
| top_level.add_include RDoc::Include.new('Mod2', '') | ||
| mod3.add_include RDoc::Include.new('Sub', '') | ||
| assert_equal [submod], mod3.ancestors | ||
| end | ||
|
|
||
| def test_store_equals | ||
| incl = RDoc::Include.new 'M', nil | ||
| incl.record_location RDoc::TopLevel.new @top_level.name | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that this part is not correct. should use Module.nesting instead of
CodeObject#parentchain.But I think RDoc::Include and RDoc::Extend does not provide enough information.
This pull request and the original implementation uses
CodeObject#parentchain instead of module nesting.Complicated example