Fork me on GitHub
#test-check
<
2016-07-25
>
zane16:07:45

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

zane16:07:14

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.

zane16:07:15

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

zane16:07:25

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

gfredericks16:07:59

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

zane16:07:21

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

zane16:07:41

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

zane16:07:08

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

gfredericks16:07:27

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

lucasbradstreet16:07:49

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

gfredericks16:07:01

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

lucasbradstreet16:07:19

Ah, my strategy doesn’t ensure uniqueness

gfredericks16:07:33

Neither does mine

lucasbradstreet16:07:45

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

lucasbradstreet16:07:31

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

gfredericks16:07:05

I'd just copy the code from master probably