Closed johanatan closed 5 years ago
Ah, I found Gen<DEST_TYPE>.map(G0, G1, ... GN)
(now called zipWith
). That should suffice for this.
Also, Gen.compose
.
Gen.compose
is definitely your friend here for tuples of large arity.
Does that mean I have to define classes to hold them or is there a way to actually produce a Tuple directly from Gen.compose?
Nope, it's polymorphic in the return type of the builder closure. All you've gotta do is provide a block that acts as a stencil for your tuple
let generator = Gen.compose { (builder) -> (Int, Float, Array<Int>) in
return (builder.generate(), builder.generate(), builder.generate())
}
Awesome. Thanks!
Given that I think you've got your answer, I'm going to close this out. Please feel free to reopen it if I'm wrong about that part.
i.e., https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/generators.cljc#L1585-L1588
and https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/generators.cljc#L82-L87
Any workarounds approaching these other than nesting
flatMap
s (which would become rather unwieldy)?