1. Meikel Brandmeyer
  2. ClojureCheck


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

Diff from to

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

     "Return a sequence of less complex value than the one given.
   In case the value is not further shrinkable, return `nil`."))
+;; # Implementation
+;; ## Basic values
+;; There are two very basic types of values.
+;; * `SimpleValue` carries a value which is not shrinkable.
+;; * `ShrinkableValue` carries a `DomainValue` and function which
+;;   specifies how the value should be shrunken.
+(deftype SimpleValue [v]
+  DomainValue
+  (value  [this] v)
+  (shrink [this] nil))
+;; These two types are used for the very basic generators. However
+;; it is perfectly possibly to define custom domain value types.
+(deftype ShrinkableValue [v f]
+  DomainValue
+  (value  [this] (value v))
+  (shrink [this] (f v)))
 (extend-protocol Generator
   (arbitrary [this size] (DomainValue. this (this size)))