-
Notifications
You must be signed in to change notification settings - Fork 167
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
Treat non-boolean return value as failed test case #130
Comments
I am not sure I understand this issue. What does efficiency, size of properties, avoiding re-computation, etc. have to do with properties returning something other than Moreover, even if such an example indeed exists, why can't you achieve what you are after by explicitly checking for equality with prop_complicated() ->
?FORALL(I, input(), complicated_property(I)). write: prop_complicated() ->
?FORALL(I, input(), complicated_property(I) =:= true). Or am I missing the point here? |
Ah, yes, I left out one crucial piece of information. Currently, when proper finds a failing test case it returns I don't understand how checking for equality with true would help me. |
I'm afraid that I don't have any example properties that I can share, they're all proprietary. |
Here's an outline of the kind of property that I have in mind: prop_big_and_bulky() ->
?FORALL(DATA,generator(),
begin
X = expensive:function(DATA),
Y = test1(X),
Z = test2(X)
Y andalso Z
end) In my case I would like to write the property as follows: prop_big_and_bulky() ->
?FORALL(DATA,generator(),
begin
X = expensive:function(DATA),
Y = test1(X),
Z = test2(X)
case Y of
false -> test_1_failed;
true -> case Z of
false -> test_2_failed;
true -> true
end) My wish is that if the property fails with I hope this clarifies what I'm after. |
It does clarify the issue, but I do not think your example is very convincing. I can definitely see why you want to avoid multiple calls to More generally, I still fail to see why you want us to change the interface of It's of course conceivable that the above example is just an over-simplification of what you really want to do. In that case, please supply something more involved (and presumably more convincing). Unrelated to the issue (and something that you most likely know already): Note that if you write your property as follows: prop_big_and_bulky() ->
?FORALL(DATA,generator(),
begin
X = expensive:function(DATA),
test1(X) andalso test2(X)
end) PropEr will not even run the |
Currently, if a property return something else than true or false, proper treats this as an error in the property and aborts testing. I think it should be treated like a failed test case instead.
The reason I would like this behavior is that sometimes I write rather big properties which test several things. If such a property fails, it can be hard to know what actually went wrong. In these cases it is useful to fail with an atom describing what went wrong.
One might argue that it is bad design to write such large and composite properties but sometimes you want to test several things which depend on some expensive computation. In these cases it is more efficient to have one big property rather than many small as they would do a lot of recomputation.
The text was updated successfully, but these errors were encountered: