You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am wondering why properties have to return a boolean result instead of a truthy result like regular ExUnit assertions. As far as I know, it means that I cannot write properties which assert using a pattern match like the following, because the assert statement with a single = does not return a boolean value:
property "returns a map" do
forall i <- pos_integer() do
assert %{val: ^i} = make_map(i) # This doesn't work and raises an error {:error, :non_boolean_result}
end
end
This is just a toy example, often I have more complicated pattern matches where it would not be as easy to swap the single = for a double ==.
Is it possible to change the assertion to check for a truthy value instead of a boolean? Or is that a constraint of PropEr?
The text was updated successfully, but these errors were encountered:
Sorry for the late delay, but if you want to assert a match, I would suppose to use match?:
property"returns a map"doforalli<-pos_integer()domatch?(%{val: ^i},make_map(i))endend
But I assume that your problem is that assert requires a boolean expression according to the Elixir docs. In PropCheck you can use assertions which is helpful alone for the better error reporting.
Hello,
I am wondering why properties have to return a boolean result instead of a truthy result like regular ExUnit assertions. As far as I know, it means that I cannot write properties which assert using a pattern match like the following, because the
assert
statement with a single=
does not return a boolean value:This is just a toy example, often I have more complicated pattern matches where it would not be as easy to swap the single
=
for a double==
.Is it possible to change the assertion to check for a truthy value instead of a boolean? Or is that a constraint of PropEr?
The text was updated successfully, but these errors were encountered: