-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite file-sniffer analysis (#412)
* Update submodule * Add ideal file-sniffer analysis implementation * Add tests for assert_call * Show in test that special forms are local functions * Add one more test case
- Loading branch information
1 parent
85c5356
commit e3e7768
Showing
8 changed files
with
287 additions
and
177 deletions.
There are no files selected for viewing
Submodule elixir
updated
86 files
This file contains 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 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
114 changes: 114 additions & 0 deletions
114
test/elixir_analyzer/exercise_test/assert_call/function_head_call_test.exs
This file contains 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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
defmodule ElixirAnalyzer.ExerciseTest.AssertCall.FunctionHeadCallTest do | ||
use ElixirAnalyzer.ExerciseTestCase, | ||
exercise_test_module: ElixirAnalyzer.Support.AnalyzerVerification.AssertCall.FunctionHeadCall | ||
|
||
test_exercise_analysis "calls in function head count", comments: [] do | ||
[ | ||
defmodule AssertCallVerification do | ||
def main_function(@jackpot) do | ||
:win | ||
end | ||
|
||
def main_function(x) when x > 100 do | ||
:too_much | ||
end | ||
|
||
def main_function([x | rest]) when is_integer(x) do | ||
main_function(x) | ||
end | ||
end, | ||
defmodule AssertCallVerification do | ||
def main_function(@jackpot) do | ||
:win | ||
end | ||
|
||
def main_function([x | rest]) when is_integer(x) and x > 100 do | ||
:too_much | ||
end | ||
end, | ||
defmodule AssertCallVerification do | ||
def main_function(x) when x == @jackpot do | ||
:win | ||
end | ||
|
||
def main_function(a, b, [x | rest]) when is_integer(x) and x > 100 do | ||
:too_much | ||
end | ||
end, | ||
defmodule AssertCallVerification do | ||
def main_function(x) when x == @jackpot do | ||
:win | ||
end | ||
|
||
def main_function(%{list: [x | rest]}) when is_integer(x) and x > 100 do | ||
:too_much | ||
end | ||
end | ||
] | ||
end | ||
|
||
test_exercise_analysis "indirect calls in function head count", comments: [] do | ||
[ | ||
defmodule AssertCallVerification do | ||
def main_function(x) do | ||
helper_function(x) | ||
end | ||
|
||
def helper_function(@jackpot) do | ||
:win | ||
end | ||
|
||
def helper_function([x | rest]) when is_integer(x) do | ||
main_function(x) | ||
end | ||
|
||
defp helper_function(x) when x > 100 do | ||
:too_much | ||
end | ||
end | ||
] | ||
end | ||
|
||
test_exercise_analysis "calls from the wrong function", | ||
comments: [ | ||
"didn't find any call to Kernel.is_integer/1 from main_function/1", | ||
"didn't find any call to |/2 from main_function/1", | ||
"didn't find any call to Kernel.@/1 from main_function/1" | ||
] do | ||
[ | ||
defmodule AssertCallVerification do | ||
def main_function() do | ||
nil | ||
end | ||
|
||
def wrong_function(@jackpot) do | ||
:win | ||
end | ||
|
||
def wrong_function(x) when x > 100 do | ||
:too_much | ||
end | ||
|
||
def wrong_function([x | rest]) when is_integer(x) do | ||
wrong_function(x) | ||
end | ||
end | ||
] | ||
end | ||
|
||
test_exercise_analysis "no calls", | ||
comments: [ | ||
"didn't find any call to Kernel.>/2 from anywhere", | ||
"didn't find any call to Kernel.is_integer/1 from main_function/1", | ||
"didn't find any call to |/2 from main_function/1", | ||
"didn't find any call to Kernel.@/1 from main_function/1" | ||
] do | ||
[ | ||
defmodule AssertCallVerification do | ||
def main_function(x) when x >= 100 do | ||
:too_much | ||
end | ||
end | ||
] | ||
end | ||
end |
This file contains 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
Oops, something went wrong.