Fork me on GitHub
#clojure-spec
<
2018-08-17
>
alexmiller01:08:38

I think both are working by swapping vars, so probably, but it might get weird. try it and see.

richiardiandrea02:08:38

Seems like it is when the with-redefs happens before the instrument. But I've got mixed feelings about this idea 😄

richiardiandrea02:08:12

Probably better not to do that

Oliver George10:08:44

Is this a common pattern: isolate a fn by stubbing everything else and running stest/check on it.

(defn check-all []
  (let [syms (stest/instrumentable-syms)]
    (doseq [sym syms]
      (let [stub-syms (disj syms sym)]
        (stest/instrument stub-syms {:stub stub-syms})
        (stest/summarize-results (stest/check sym))
        (stest/unstrument)))))

alexmiller12:08:16

First time I’ve seen it, but interesting

Oliver George01:08:35

I was thinking it would give you confidence that the inputs and outputs through the code match up. So essentially a cheap type checking substitute. The downside of that approach is that for full code coverage the generated data needs to trigger all branches of conditionals… I think that’s probably not something you can rely on.

colinkahn17:08:09

Looks like it isn't an option, but curious if there's a way to specify an fspec for check like you can for excercise-fn

colinkahn17:08:09

My goal is to check a fn with an fspec whose :fn is specific to a more narrow generator.

alexmiller18:08:17

you can do that with instrument first

alexmiller18:08:09

with the :replace functionality

alexmiller18:08:16

if I understand your goals that is

colinkahn18:08:40

Looking at the docs for instrument I think :spec should do what I want, but trying the following still uses the registered fdef for files-reducer instead of the override fspec

colinkahn18:08:49

(st/instrument `files-reducer {:spec {`files-reducer (s/fspec :args (s/cat) :ret any? :fn (fn [_] false))}})
(expound/explain-results (st/check `files-reducer))