Commits

Meikel Brandmeyer  committed 469a528

Make ClojureCheck compatiable with Clojure >= 1.2

  • Participants
  • Parent commits 85c314b

Comments (0)

Files changed (1)

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

 ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 ; DEALINGS IN THE SOFTWARE.
 
-(ns ^{:author "Meikel Brandmeyer"
+(ns #^{:author "Meikel Brandmeyer"
       :doc
   "clojurecheck - property based testing
 
   (:use clojure.test))
 
 (defprotocol Generator
-  (^{:added "2.1"} arbitrary
+  (#^{:added "2.1"} arbitrary
     [generator size]
     "Choose an arbitrary value by virtue of the given generator."))
 
   [& {:keys [lower upper] :or {lower -32768.0 upper 32767.0}}]
   (NumberDomain. rand lower upper))
 
-(def ^{:doc "Generates a random boolean value. Ignores the size guidance"
-       :added "2.0"}
+(def #^{:doc "Generates a random boolean value. Ignores the size guidance"
+        :added "2.0"}
   bool
   (reify
     Generator
   (let [f (if (fn? f) f (constantly f))]
     (reify Generator (arbitrary [this size] (arbitrary gen (f size))))))
 
-(def ^{:doc "Number of trials a property is tested with generated input.
+(def #^{:doc "Number of trials a property is tested with generated input.
   Default is 1000."
-       :added "2.0"}
+        :added   "2.0"
+        :dynamic true}
   *trials*
   1000)
 
 (defn *size-scale*
   "The scale function used to scale up the size guidance with increasing
   trials while testing a property with generated input."
-  {:added "2.0"}
+  {:added "2.0" :dynamic true}
   [n]
   (if (even? n)
     (/ n 2)
             (binding [report report-fn]
               (prop (.value input)))
             (let [failures (filter #(-> % :type (not= :pass)) @results)]
-              (if (seq failures)
+              (when-let [failures (seq failures)]
                 (do-report {:type     ::property-fail
                             :message  msg
                             :locals   locals
                             :input    (.value input)
                             :attempts n
-                            :failures failures})
-                (recur (inc n))))
+                            :failures failures})))
             (catch Throwable t
               (do-report {:type    ::property-error
                           :message msg
                           :locals  locals
                           :input   (.value input)
-                          :attempt n
-                          :error   t}))))))))
+                          :error   t})))
+          (recur (inc n)))))))
 
 (defmacro property
   "Defines a property consisting of a binding vector as for let-gen