Fork me on GitHub
#clojure-spec
<
2018-09-30
>
misha12:09:15

"it" = "same keys order in map"

bbrinck13:09:40

@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?

taylor14:09:44

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

taylor14:09:18

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?

taylor15:09:15

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?

taylor15:09:45

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

Garrett Hopper15:09:04

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

taylor15:09:06

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

taylor15:09:47

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

taylor15:09:27

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

andy.fingerhut16:09:32

@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.

bbrinck17:09:04

@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.