-
Notifications
You must be signed in to change notification settings - Fork 155
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
Add samples to Generator and Shrinker documentation #218
Comments
Awesome work so far. I have pushed the updated docs. |
With #266 we've now covered all the combinators under the Useful Generator Combinators with the exception of Can anyone think of a simple, reasonable example? |
Nice.
Perhaps an example where we are building a list or data structure, where with each added element the chance of finding another element with that satisfies some global invariant becomes smaller. If we get E.g. concretely generate a list of distinct elements from a given generator - where the generator has a generic type, so we don't know much about how easy it is to generate a list of district elements, e.g. compare a list of distinct bools vs distinct floats. We can do this by calling |
Should we document If we should document it, I'd be happy to open a PR. |
Would you ever use |
I wouldn't use it when writing properties. I might rarely use it when writing generators, e.g.: instead of I agree that it should be rarely used. We could still document why though, and also what it does... |
Probably better not in this context. Unlikely it should have been part of the API in the first place anyway. |
Would it make sense to document An easy way to document that generator can be via |
I think it'd be fine to add an example of I have to admit, however, that I still don't understand when I'd ever use If I understand the intent of this GitHub issue correctly, its purpose is to make the introduction to Generators and Shrinkers more accessible, by showing some examples. The purpose of the The reason I bring this up is that if we make the file too big, it'll have a detrimental effect, because people will give up when they see the sheer size of it. |
All that said, another sometimes useful function is |
True. |
I'm going to close this general topic, as great progress has been made here. Feel free to open specific issues if there is anything to discuss, or even better, a PR with additional documentation suggestions (though heeding @ploeh's wise words about the difference between introductory documentation and API docs.) |
While talking to people about FsCheck I had the following idea to improve the documentation.
The documentation page https://fscheck.github.io/FsCheck/TestData.html which is generated from https://github.com/fscheck/FsCheck/blob/master/docs/content/TestData.fsx currently feels very abstract - I think it would be improved if some of the generators and shrinkers discussed would show some actual output. This would also show people how to write/test generators/shrinkers and get a feel for what they do.
Concretely, I would suggest to add executed code samples (using FSharp.Formatting's output capturing, like in the other docs) that essentially call
Gen.sample
and the shrinker function with an example value.The text was updated successfully, but these errors were encountered: