Commits

Meikel Brandmeyer committed 01e3820

Implementation basic values

Comments (0)

Files changed (1)

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
   clojure.lang.Fn
   (arbitrary [this size] (DomainValue. this (this size)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.