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
Issue with generated functions that return boxed exceptions #128
Comments
Not exactly, it's just that you're generating two different Exception instances to the left and the right of your property, and they compare false. Try instead
Ultimately this is due to a very subtle issue in the definition of Gen.delay, in the computation expression for
Your original definition works fine (i.e. generates the same instance of I'm going to sleep on whether the existing behavior is a bug or a feature, currently leaning towards the former, but am a bit cautious since the existing definition of delay is pretty ancient. |
Awesome! I've been trying to figure this one out for a while. For reference, I went with this approach since I have a long list of exceptions: let exceptionGenerator : Gen<exn> =
Gen.elements [
...
Exception()
...
] Thanks for the help. Interested to see what you decide. |
Sure, you can workaround by binding the different exception instances outside of the computation builder, i.e.
But I'll remove the delay anyway. I can't think of any practical benefits and it seems counter-intuitive (and inefficient). |
Heads up: I've had to revert my change to delay in 2.0.6 because it was causing problems. It has to be so that each execution of a computation expression generates a new object; for example, think about what happens if you generate a mutable object in the computation expression, then set its value....also, this broke while/for in the computation expression (which is much the same problem, they used delay under the hood), see e.g. #131 . So keep using |
I last visited this before delay was removed, so still using Thanks for the heads up. |
I've reduced my issue down to the following:
with this, I get the following output:
I only have problems with tests that generate functions with the signature
int list -> Result<int list, exn>
(other tests compare generatedResult
types containing exceptions without issue).I'm not quite sure what's happening here but I suspect that the exception is somehow being unintentionally raised.
The text was updated successfully, but these errors were encountered: