Fork me on GitHub

"it" = "same keys order in map"


@misha I may be misunderstanding your question, but the order of a map is consistent, (i.e. for the same map m, (first m) will always return the same thing, since maps are seqable?).

Garrett Hopper14:09:24

Is the only difference between using spec/valid? in the pre/post map of a function and spec/fdef that spec/fdef can be specified elsewhere?


you have to instrument fdef’d functions, and that won’t check the function return value like :post does


pre/post checks will run by default, but instrumentation is opt-in

Garrett Hopper14:09:32

I'm noticing that instrument-all is no longer available. Is it common to just instrument a single function while testing it nowadays?


calling instrument with no args will instrument everything that’s been loaded

Garrett Hopper15:09:12

fdef doesn't verify the output from the :ret parameter though?

Garrett Hopper15:09:20

At least while using instrument?


right, instrumented functions will only assert the fdef :args spec

Garrett Hopper15:09:04

Huh, is there anything that actually uses the :ret then?


there’s a lib called Orchestra with another version of instrument that adds return value checking


yeah, if you check an fdef function it uses the :ret spec (and :fn if it exists)


check towards the bottom of the clojure.spec guide for check


@bbrinck I do not know your use case exactly, but as long as you are only relying on that for the same identical map m, not two different maps m1 and m2 where (= m1 m2). If you try to rely on (= (first m1) (first m2)) you will often be disappointed. But yes, you can rely on (= (seq m) (seq m)) being true.


@andy.fingerhut good point! Yes, this is for the identical map - the “in” path returned by spec is only valid for the data you originally check, NOT other data that happens to be equal to the original data.