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 Generex#random(RandomSource random) so random source can be provided on a call-by-call basis #50

Open
vlsi opened this issue Sep 17, 2019 · 0 comments

Comments

@vlsi
Copy link

vlsi commented Sep 17, 2019

Currently it is hard to integrate Generex and https://github.com/pholser/junit-quickcheck.

Here's "example" implementation: https://github.com/pholser/junit-quickcheck/blob/61e751ceb55cb767d7ef150959df0244543fcd64/examples/src/test/java/com/pholser/junit/quickcheck/examples/text/Structured.java#L51

There are two problems there:

  1. Generex(pattern) initialization is performed on each generation. In other words, Generex parses the pattern and builds regex automata for each generate call which is waste.

  2. Cloning Random is kind of hard. In practice, Generex#prepareRandom does not need the full power of Random, so it might make sense to add a thin interface RandomSource with methods like nextInt(int) and nextFloat().

Then end-users could instantiate Generex just once, and pick random values as needed (providing it with RandomSource instance).

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

1 participant