-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Rewrite file-sniffer analysis #412
Conversation
@jiegillet could you review this one? |
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.
Wonderful, it's nice to see that assert_call
was already powerful enough to handle that, thank you for adding the new tests to highlight the behavior.
Sorry that I took so long to review, I still thought that assert_call
needed to change, and I was slowly gathering motivation to deep dive back into it, but it seems I never had enough haha. I'm glad you reminded me :)
The code looks great, I just left a suggestion to add a test or two, but it's just a formality.
end | ||
] | ||
end | ||
|
||
test_exercise_analysis "doesn't use pattern matching", | ||
comments: [Constants.file_sniffer_use_pattern_matching()] do | ||
test_exercise_analysis "doesn't use <<>> nor ::", |
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.
The comment should be triggered if the solution only uses one of the forms right? Should we add tests to check that?
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 added a test with just <<>>
but I don't think I can add a test with just ::
. It's used for defining binary sizes, so you can't really use it without using the binary special form...
GitHub doesn't seem to let me re-run the external tests, I can't find the button, I don't know why. |
You can only rerun the tests if the latest test run isn't too old... I think maybe 2 or 4 weeks. |
Ah that makes sense :) |
Resolves #407
Originally this PR was called:
After a deep dive, I realized that
assert_call
is already capable of finding calls in function heads.I have initially made a wrong assumption. I thought that the
Kernel
module alone is implicitly imported into each new module. That is only partially correct. TheKernel.SpecialForms
module is also implicitly imported, with some important differences:Kernel.SpecialForms
, whereas you can modifyKernel
imports by making them explicit and passing:only
/:except
optionsKernel.SpecialForms
macros cannot. They look exactly like usages of local function/macros.I was also confused which module provides which macro, I thought
<<>>
and::
comes fromKernel
, but it coems fromKernel.SpecialForms
TL;DR: we can use
assert_call called_fn name: :<<>>
to check for calls of special forms with no problems and no modifications necessary. It is not allowed to overwrite those special forms anyway, so you won't have a conflicting local function.Related PR: exercism/website-copy#2306