Skip to content
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

Allow for global frequency #182

Closed
jeremyheiler opened this issue Sep 27, 2017 · 1 comment
Closed

Allow for global frequency #182

jeremyheiler opened this issue Sep 27, 2017 · 1 comment

Comments

@jeremyheiler
Copy link

jeremyheiler commented Sep 27, 2017

I am generating a tree of nodes. Each node is represented by a Node interface, which has a handful if implementations, each having their own generator. It appears that saying gen().type(Node.class) picks one of the generators with a uniform distribution.

I really like this. However, I would like one of the nodes to be chosen more often than the others. Of course, I can implement this by using Gen.frequency. However, applying this globally would alleviate the need to keep a separate list.

Would it make sense to have an annotation on the generator that determines its frequency, if it's one of many generators to be chosen from? (Maybe this is currently possible, and I haven't figured out how to do it.) If this makes sense to do, I wouldn't mind taking a stab at implementing it.

This may be related to #170.

@pholser
Copy link
Owner

pholser commented Oct 15, 2017

@jeremyheiler Thanks for your interest - sorry it's taken so long to respond. I could see that this might be useful, but I'm not certain it wouldn't overcomplicate. Can you post an example of what your property-based test might look like before/after your proposed feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants