-
Notifications
You must be signed in to change notification settings - Fork 154
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
Identity checking #280
Comments
I'm not so sure about it. It seems weird to me to improve the debugging experience for one specific kind of case (which I admit, is common) but not do it for the rest. There are some other subjective criteria at play for me at least:
So overall, I'm skeptical of this change. I am not a "hard no" on it though. But that's the way I'm leaning. |
Reluctance to add complexity, especially to proc macros, is totally relatable. In practice, we would differentiate based on an argument (
It's definitely an option. It feels a bit more natural printing two lines of debug messages via two print-like statements but that's just a preference. What actually bothers me, if using
I do have a few examples in the code I'm currently working on, but it's not open-sourced, yet.
Yes, it would indeed be easy to implement as an independent macro on top of the existing one. But in the end, it's just a minor inconvenience. These test types I described or additional macros wouldn't exactly be a must have. I can live without them. I will probably play around and maybe post such a macro example here at some point. |
After reading the documentation some more, I concluded that using the |
Some classes of properties checked with this crate may merit some convenience functionality. One of those classes being properties which essentially check whether some transformation is equivalent to identity.
One domain in which I found this approach useful are parsers: you'd format some arbitrary data-structure and read it back through the parser, but I suspect you end up constructing pseudo-identities in quite a few domains. In fact, the very example in the readme tests for such a property:
Depending on the complexity of the functions involved in the construction, tracking the input reported by quickcheck through the code may be rather tedious, even after the inputs are shrunk. Knowing how exactly the result of the pseudo-identity differs from its input can help narrowing down the error. So users may end up printing both as part of the test:
However, this also results in them being printed during the shrinking, which is not ideal. I assume this wouldn't be the case if using
TestResult::error
instead ofeprintln
, and we can always construct the test ourselves. But still, we end up writing common boilerplate for that class of tests. It would be nice if we could write the following, instead:Quickcheck would generate a test which does the comparison between the function's input and output. If they differ, it would also print both input and output after shrinking.
A generalization of this class would be cases in which we want to compare two values. We'd write:
And the macro would generate a test which compares the two values in the tuple and prints them (along with the input) after shrinking. In this case, the output (i.e. the tuple element) would not need to be of the same type as the inputs.
This would obviously be a convenience feature. I volunteer implementing it, but I'd like to hear opinions on whether this is actually something anyone else would find useful first.
The text was updated successfully, but these errors were encountered: