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

Add flatMap() on Generators #31

Open
neilgall opened this issue May 23, 2017 · 1 comment
Open

Add flatMap() on Generators #31

neilgall opened this issue May 23, 2017 · 1 comment

Comments

@neilgall
Copy link

neilgall commented May 23, 2017

Sometimes I want to control a generator based on the value generated from another. A simple case is where some value should be one of several subclasses. For example flatMap on generators would allow an integer to be generated, and one of the subclasses generated based on the value of the integer.

Something like:

class Data {}
class A extends Data {}
class B extends Data {}
class C extends Data {}

class DataContainer { Data data }

Gen.type(DataContainer,
    data: Gen.integer(0..2).flatMap{ Gen.type([A,B,C][it]) }
)
@Bijnagte
Copy link
Owner

Interesting, I have been swamped with work and home stuff recently so I apologize for not getting to this sooner. I will have some time this weekend to think about an implementation unless you have already thought about how you might accomplish this.

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