propcheck
propcheck copied to clipboard
Strange behavior when adding code after forall
I encountered this strange behaviour today. Given the following code:
property "some property" do
forall i <- integer() do
IO.inspect(i, label: "i")
test_some_property()
end
end
property "some other property" do
forall i <- integer() do
IO.inspect(i, label: "ii")
test_some_property()
end
test_some_other_property()
end
defp test_some_property do
true
end
defp test_some_other_property do
true
end
only the code block with the label: i
with be executed. Obviously it makes little sense to have test_some_other_property()
after the forall
but given my code was more complex than the example it took me a while to find the problem.
Is that the expected behaviour? Would it make sense to give a warning or error?
Hi @pallix , nice catch, this is similar to #112. We should warn about that in the documentation. Since propcheck relies heavily on macros and code generation, it could be difficult to identify that situation (i.e. the Elixir compiler does not detect that situation, so we would have to do that by ourselves).
Happy to receive a pull request!
In #112 both code blocks are executed but here only the one external to the forall
. Am I correct?