-
Notifications
You must be signed in to change notification settings - Fork 157
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
Gen.uri #331
Gen.uri #331
Conversation
This particular type addresses the concern of generating scheme values for Uri values.
This particular type addresses the concern of generating the host part of Uri values.
A URI host can be either an IP address or a host name. When defining a shrinker, it'll be important to determine if the original value was an IP address or a host name.
This is looking really good. I think in terms of which arbitrary types are good for inclusion in FsCheck: as many as possible! :) The only time I'd draw a line is if it would incur an additional dependency; in those cases I have previously offered to start a separate project under the FsCheck organization and that offer still stands. As far as this PR is concerned, it's looking great. One suggestion, it looks like this is developing in a sort of sub-API to generate Uris. I wonder if we can make the connection between the different Uri-related instances clearer by grouping them together in the API somehow - perhaps on a separate class, so you'd see them as |
|> System.String | ||
|> UriScheme } | ||
// While these well-known scheme are available in the full BCL as | ||
// Uri.UriSchemeFile, Uri.UriSchemeFtp, etceterat, they aren't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: etceterat → etcetera
I like the idea of having a 'sub-API' like I can't say that I fully understand the way FsCheck picks up Arbitraries, but would these Arbitraries automatically be included if they belong to a new type? |
They wouldn't be automatically picked up, but you can just add the nested class here once and for all: https://github.com/fscheck/FsCheck/blob/master/src/FsCheck/Arbitrary.fs#L165 |
OK, thank you; I'll try that. This PR is falling behind master, so I'm going to close it as is, do some work on it, rebase it on master, and open a new PR when it's ready for another review. |
How about calling it |
No objections. Please consider how that interacts with "utility" methods on |
That may be an argument for Thank you. |
How would you even implement something like Any ideas? |
I was thinking it would just be a property Could also turn the |
Is that possible? AFAICT, the reason that it's a class in the first place is to work around F#'s restriction against circular references. That's the main reason that so far, it's resisted all my attempts at refactoring it, as mentioned in another thread. |
Is it something |
I'm not sure I follow... |
I guess I don't understand where the circular references come into play here... |
This pull request is mostly a request for comments, and shouldn't be seen as an entirely complete body of work.
The aim is to provide building blocks for creating various forms of
Uri
values. This is done though various 'role' types that each have their own generators and shrinkers. This pull request introduces the following Arbitraties:Using these building blocks, it's possible to create truly arbitrary
Uri
values:, or, if you want only 'web' URLs:
Actually, these examples cheat a bit, because they only generate strings, but one can easily generate
Uri
values from the above generators by usingGen.map Uri
or similar techniques.This PR doesn't include support for ports, query strings, authentication data, or fragments, because I first wanted to ask whether this is even something that's interesting to include in FsCheck.
If so, it's also my intent to introduce a built-in
Uri
Arbitrary that combines all of the above Arbitraties, as well as a built-inWebUrl
Arbitrary that generates only HTTP-based URLs (for use with testing of e.g. RESTful services).