Fork me on GitHub
#clojure-spec
<
2019-02-18
>
jaihindhreddy-duplicate07:02:13

I want to spec a fn target, like this:

(s/fdef target
        :args (s/+ ::a)
        :ret ::a
        :fn #(= (f (:ret %) i)
                (apply g (map (fn [x] (f x i))
                              (:args %)))))

jaihindhreddy-duplicate07:02:51

Where f and g are functions I've written, and i is any integer i.e, for any integer i, this property must hold. Can I express this with spec, or should I drop down to test.check?

misha13:02:39

> I’ve been working on the new select functionality for spec 2 this week ♥️

♥️ 5
gfredericks14:02:36

@jaihindh.reddy I think if i is not an arg to target then you can't easily do that with spec; you'd have to maybe write another function target* that also takes i, and you'd only use it for testing, which is a bit weird

5