-
Notifications
You must be signed in to change notification settings - Fork 14
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
Handle nested modules #52
Conversation
test/patch.jl
Outdated
|
||
end | ||
|
||
import ModA |
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.
For 0.7, this will need to be
if VERSION >= v"0.7.0-DEV.1877"
import .ModA
import .ModA: bar, ModB
else
import ModA
import ModA: bar, ModB
end
because of JuliaLang/julia#23579
Codecov Report
@@ Coverage Diff @@
## master #52 +/- ##
==========================================
- Coverage 93.52% 92.14% -1.39%
==========================================
Files 4 4
Lines 278 280 +2
==========================================
- Hits 260 258 -2
- Misses 18 22 +4
Continue to review full report at Codecov.
|
test/patch.jl
Outdated
x::String | ||
end | ||
|
||
end |
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.
Can we indent the submodule content for clarity?
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.
Or even just end # ModA
comments
src/Mocking.jl
Outdated
push!(modules, m) | ||
m = m.args[1] | ||
end | ||
push!(modules, m) |
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.
Why the change?
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.
lol, you fixed this in a very different way than I thought you would. XD
test/patch.jl
Outdated
@@ -78,8 +101,17 @@ end | |||
] | |||
for p in patches | |||
@test p.signature == :(f(h::Core.Int64=$RAND_EXPR(Core.Int64))) | |||
@test p.modules == Set([:Core, RAND_MOD_EXPR]) | |||
@test p.modules == Set([:Core, :Base, RAND_MOD_EXPR]) |
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 guess we'll need to start special casing |
Yeah, I'm not sure how to make these tests work on 0.7 because:
Maybe I'll only run the test on 0.6 for now with a comment on why. |
Could you not use |
It works when you're in Main, like at the REPL. If you're in a package, it won't work, because each package has its own top level module (e.g., |
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'm fine with having this tested only on 0.6 for now.
Currently, using nested modules can result in an
UndefVarError
.This is because the patch is only importing the top level module while the method is using a fully specified type signature:
The solution should be to just recursively import all the parent modules.