Meikel Brandmeyer  committed 71d6b27

Adapt combinators to new interface

  • Participants
  • Parent commits 1f8a4d2

Comments (0)

Files changed (1)

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

   (generators {chs (list characters :length length)}
     (apply str chs)))
+;; ## Generator transformers
 (defn transform
   "Generates a value according to `gen` and calls `f` with the generated
   value—not the domain value. The return value of `f` becomes the new
                     (some (fn [[c f]] (when (< dice f) c)) choices)))]
-      (arbitrary [this size] (arbitrary (choose) size)))))
+      (arbitrary [this size] (generate (choose) size)))))
 (defn one-of
   "Chooses one of the given generators with equal probability.
       [this size]
-      (when-let [dom-value (arbitrary generator size)]
-        (when (pred (.value dom-value))
-          dom-value)))))
+      (when-let [dval (arbitrary generator size)]
+        (when (pred (value dval))
+          dval)))))
 (defn sized
   "Modify the size guidance according to f and pass it on to the
       (reset! results [])
       (if (< *trials* n)
         (report {:type :pass})
-        (let [input (->> n *size-scale* (generate-input gen))]
+        (let [input (->> n *size-scale* (generate gen))]
             (binding [report report-fn]
-              (prop (.value input)))
+              (prop (value input)))
             (let [failures (filter #(-> % :type (not= :pass)) @results)]
               (when-let [failures (seq failures)]
                 (do-report {:type     ::property-fail
                             :message  msg
                             :locals   locals
-                            :input    (.value input)
+                            :input    (value input)
                             :attempts n
                             :failures failures})))
             (catch Throwable t
               (do-report {:type    ::property-error
                           :message msg
                           :locals  locals
-                          :input   (.value input)
+                          :input   (value input)
                           :error   t})))
           (recur (inc n)))))))