1

The test.check library provides a generate function that takes a generator and size and returns a single value from the generator with the given size, but it gets its seed nondeterministically. The library also provides a quick-check function that takes a seed and tries a property using that seed, but it doesn't give a way to control the size or retrieve the return value of the property beyond its truthiness or falsiness.

Is there a way to generate a value with an explicit seed and size, for purposes such as deterministic simulation on generated data?

Sam Estep
  • 12,974
  • 2
  • 37
  • 75
  • 2
    The direct answer is `(rose/root (gen/call-gen g (random/make-random seed) size))` But the reason this isn't more straightforward is that it's not usually necessary, so I'm curious for more detail about what you're trying to accomplish. If there's no better fit for what you're doing, I've considered adding another arity to `gen/generate` that would make this easier. – gfredericks Jun 12 '17 at 20:13
  • @gfredericks Thanks, that works nicely! The reason is that I'm comparing strategies for performing a task, and it's easier to do such a comparison when I can easily generate the same input repeatedly to pass to multiple strategies. Without being able to generate from a seed, the input changes every time I reload my code unless I store it somewhere else, which is inconvenient. Having another arity in `generate` that supports this would indeed be valuable, I think. – Sam Estep Jun 12 '17 at 20:29
  • 2
    I added [this](https://github.com/clojure/test.check/commit/23e1fcc1bb7f3f2d0202ed99eee202a0b1f2c652) commit on master, so it should be included in the next release. – gfredericks Jun 13 '17 at 12:29

0 Answers0