anchor.diff:  
   To learn more about generators, read the test.check http://clojure.github.io/test.check/intro.html[tutorial] or http://clojure.github.io/test.check/generator-examples.html[examples]. Do keep in mind that while clojure.spec.gen is a large subset of clojure.test.check.generators, not everything is included.
   
  +== Testing
  +
  +We mentioned earlier that `clojure.spec.test` provides tools for automatically testing functions. When functions have specs with generators, we can use http://clojure.github.io/clojure/branch-master/clojure.spec-api.html#clojure.spec.test/check-var[`check-var`], to automatically check the specs are correct. 
  +
  +`check-var` will generate arguments based on the `:args` spec for a function, invoke the function, and validate the `:ret` and `:fn` specs were satisfied.
  +
  +[source,clojure]
  +----
  +(require '[clojure.spec.test :as stest])
  +
  +(stest/check-var #'ranged-rand)
  +;;=> {:result true, :num-tests 100, :seed 1466020849335}
  +----
  +
  +`check-var` also takes a number of options to specify how many tests to run, the "size" of the inputs (a notion that test.check uses to measure the complexity of inputs), the seed (if you wish to reproduce a failure, and an optional reporting function).
  +
  +Imagine instead that we made an error in the ranged-rand code and swapped start and end:
  +
  +[source,clojure]
  +----
  +(defn ranged-rand  ;; BROKEN!
  +  "Returns random int in range start <= rand < end"
  +  [start end]
  +  (+ start (long (rand (- start end)))))
  +----
  +
  +This broken function will still create random integers, just not in the expected range. Our `:fn` spec will detect the problem when checking the var:
  +
  +[source,clojure]
  +----
  +(stest/check-var #'ranged-rand)
  +;;{:result {:clojure.spec/problems {[] {:pred (>= (:ret %) (-> % :args :start)),
  +;;                                      :val {:args {:start -1, :end 3}, :ret -3},
  +;;                                      :via [],
  +;;                                      :in []}},
  +;;          :failed-on :fn},
  +;; :seed 1466023411366,
  +;; :failing-size 0,
  +;; :num-tests 1,
  +;; :fail [(-1 3)],
  +;; :shrunk {:total-nodes-visited 2,
  +;;          :depth 1,
  +;;          :result {:clojure.spec/problems {[] {:pred (>= (:ret %) (-> % :args :start)),
  +;;                                               :val {:args {:start 0, :end 3}, :ret -2},
  +;;                                               :via [],
  +;;                                               :in []}},
  +;;                   :failed-on :fn},
  +;;          :smallest [(0 3)]}}
  +----
  +
  +`check-var` has reported an error in the `:fn` spec. We can see the arguments passed were -1 and 3 and the return value was -3, which is out of the expected range. At the bottom, test.check takes one step further though and "shrinks" the invalid inputs to find simpler/smaller inputs that yield the same error. Here the "simpler" inputs were 0 and 3, which is not much different, but on complicated data, shrinking is a killer feature for finding failing examples.
  +
   == Wrapping Up
   
   In this guide we have covered most of the features for designing and using specs and generators. We expect to add some more advanced generator techniques and help on testing in a future update.
  
positive.code: (s/explain-data ::name-or-id :foo)
  ;;=> {:clojure.spec/problems
  ;;    {[:name] {:pred string?, :val :foo, :via []},
  ;;     [:id] {:pred integer?, :val :foo, :via []}}}
  ----
  
  We'll see some more examples later on.
  
negative.code: 
  The pre- and post-condition example in the previous section hinted at an interesting question - how do we define the input and output specifications for a function or macro?
  
  Spec has explicit support for this using http://clojure.github.io/clojure/branch-master/clojure.spec-api.html#clojure.spec/fdef[`fdef`], which defines specifications for a function - the arguments and/or the return value spec, and optionally a function that can specify a relationship between args and return.
  
  Let's consider a `ranged-rand` function that produces a random number in a range:
  
  [source,clojure]
  ----
  (defn ranged-rand
    "Returns random int in range start <= rand < end"
    [start end]
    (+ start (long (rand (- end start)))))
  ----
  
  We can then provide a specification for that function:
  