Skip to content

Add Generex#random(RandomSource random) so random source can be provided on a call-by-call basis #50

@vlsi

Description

@vlsi

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions