Fork me on GitHub
#test-check
<
2016-08-29
>
lvh17:08:57

Is there something in test.check for producing equal-but-internally-different data structures? (Trying to check if a serialization format is deterministic).

lucasbradstreet18:08:23

@lvh where two data structures are equal but will serialize/deserialize to something equal but distinct? e.g. clojure maps and records can be equal, but a record should round trip back to a record

lvh18:08:50

Oh, right — that’s a good point 🙂

lvh18:08:27

I guess I’m mostly thinking of issues like map key order or set order

lucasbradstreet19:08:28

Ah. Those two are interesting although, at least in clojure, I don’t think/don’t count them as part of the contract

lucasbradstreet19:08:27

https://github.com/ztellman/collection-check might be handy if you’re interested in stuff like maps/sets/etc, though it wasn’t really built for what you want

Alex Miller (Clojure team)20:08:08

maps and sets are not ordered - equality does not consider them (and there are no guarantees around it)

lucasbradstreet20:08:13

I remember from the google groups discussion that the order of keys and the order of vals, on an identical? map, are guaranteed to be in the same order, but that was it

gfredericks23:08:48

@lvh I think if you could enumerate the sort of distinctions you're aiming at it wouldn't be hard to put together yourself

gfredericks23:08:12

(defn gen-tweak "Returns a generator of variants of x such that (= x x')" [x] ...)