test-check

zane 2016-07-25T16:08:45.000012Z

@gfredericks: The thunk is literally producing the generated value. e.g. (fn [& _] (java.util.UUID/randomUUID)).

zane 2016-07-25T16:09:14.000013Z

I see now that make-gen doesn't take a thunk (my bad!) but I'm still wondering what the right way to go about this is.

zane 2016-07-25T16:10:15.000014Z

The best thing we could come up with was: (clojure.test.check.generators/fmap (fn [_] (java.util.UUID/randomUUID)) (clojure.test.check.generators/return nil))

zane 2016-07-25T16:10:25.000015Z

But that obviously feels pretty gross since the work of clojure.test.check.generators/return is discarded.

2016-07-25T16:16:59.000017Z

@zane: would gen/uuid work for you or are you doing something else?

zane 2016-07-25T16:17:21.000018Z

Ah, I don't think gen/uuid exists in the alpha we're using.

zane 2016-07-25T16:17:41.000019Z

Assuming it doesn't, what would the right workaround be?

zane 2016-07-25T16:18:08.000020Z

(Maybe the answer is: Update your alpha. 😄)

2016-07-25T16:18:27.000021Z

You could generate a collection of hex characters and use gen/fmap to convert then to a uuid

zane 2016-07-25T16:19:11.000022Z

Eek.

lucasbradstreet 2016-07-25T16:19:49.000023Z

You can also generate two longs and build a uuid with it

2016-07-25T16:20:01.000024Z

In general you want to use the randomness of the framework, not calling any random functions yourself, else you lose determinism and shrinking

lucasbradstreet 2016-07-25T16:20:19.000025Z

Ah, my strategy doesn’t ensure uniqueness

2016-07-25T16:20:33.000026Z

Neither does mine

lucasbradstreet 2016-07-25T16:21:09.000027Z

This is what you’d use if you don’t need uniqueness https://docs.oracle.com/javase/7/docs/api/java/util/UUID.html#UUID(long,%20long)

lucasbradstreet 2016-07-25T16:21:45.000028Z

I’ve also used with-redefs to override my internal random uuid generation function, and I just generated the seed via test.check

lucasbradstreet 2016-07-25T16:22:31.000029Z

A bit hacky, but it saved me from having to pass down a UUID seed and changing a lot of code

2016-07-25T16:24:05.000030Z

I'd just copy the code from master probably

lucasbradstreet 2016-07-25T16:29:56.000031Z

mmm