test-check

wotbrew 2017-01-16T15:09:19.000162Z

I want to write a generator that zipmaps values in coll-a to values in coll-b, but with the restriction that each entry in coll-a will be present in keys of the resulting map. Is this possible?

wotbrew 2017-01-16T15:17:02.000163Z

I've got something like this

(let [a [1 2 3]
           b [:foo :bar]]
       (gen/fmap (partial apply zipmap)
                 (gen/tuple
                   (gen/shuffle a)
                   (gen/return (cycle b)))))

wotbrew 2017-01-16T15:17:18.000164Z

not sure if there is a better way to do it

2017-01-16T16:10:47.000167Z

how about (let [a [1 2 3], b [:foo :bar]] (gen/let [vals (gen/vector (gen/elements b) (count a))] (zipmap a vals))) @danstone

wotbrew 2017-01-16T16:17:03.000168Z

Thats great - thanks @gfredericks

2017-01-16T16:20:43.000169Z

np