ClojureCheck / src / main / clojure / clojurecheck / core.clj

Diff from to

File src/main/clojure/clojurecheck/core.clj

   (value  [this] (value v))
   (shrink [this] (f v)))
+;; Some of Clojure's internal types are also acting as domain values.
+;; The map to the corresponding behaviour of the given type in the
+;; role of an generator.
+(extend-protocol DomainValue
+  ;; Sequences are considered as tuples of generated values.
+  ;; Shrink one after the other.
+  clojure.lang.ISeq
+  (value  [this] (map value this))
+  (shrink [this] (mapcat shrink this))
+  ;; Maps are also acting as domain values. The keys are fixed
+  ;; but the values are domain values. Again we try to shrink
+  ;; here one after the other.
+  clojure.lang.IPersistentMap
+  (value  [this] (into (empty this) (for [[k v] this] [k (value v)])))
+  (shrink [this] (for [[k v] this sv (shrink v)] (assoc this k sv))))
 (extend-protocol Generator
   (arbitrary [this size] (DomainValue. this (this size)))