Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In hedgehogqa/fsharp-hedgehog#154, @cmeeren suggested that the test of
withNull
was inefficient. Here are the runtimes of this test reported by the Test Explorer in Visual Studio.In fact, this test is among the fastest tests in the test suite.
This PR rewrites this test to do exactly what is desired by the test. It does not generate unnecessary values and it does not do any retests with shrunk values. It is easy to verify that this test passes for the right reason because removing the call to
withNull
causes the test to fail. Here are the runtimes reported by the Test Explorer in Visual Studio.This rough analysis shows that this test that was already among the fastest got a little bit faster.
My rewrite of this test contains more code. It also contains more lines although some of them could be combined. Another disadvantage is that
Hedgehog.Random
might disappear one day soon. This will change the API, but I think the functionality will remain.On the positive side, I think this implementation is more idiomatic.