make-arg-checker

clojure.contrib.mock

  • (make-arg-checker arg-preds arg-pred-forms)
Creates the argument verifying function for a replaced dependency within
the expectation bound scope. These functions take the additional argument
of the name of the replaced function, then the rest of their args. It is
designed to be called from the mock function generated in the first argument
of the mock info object created by make-mock.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/mock.clj:116 top

(defn make-arg-checker
  "Creates the argument verifying function for a replaced dependency within
the expectation bound scope. These functions take the additional argument
of the name of the replaced function, then the rest of their args. It is
designed to be called from the mock function generated in the first argument
of the mock info object created by make-mock."
  [arg-preds arg-pred-forms]
  (let [sanitized-preds (map (fn [v] (if (fn? v) v #(= v %))) arg-preds)]
    (fn [fn-name & args]
      (every? true?
        (map (fn [pred arg pred-form i] (if (pred arg) true
                                          (unexpected-args fn-name pred-form arg i)))
          sanitized-preds args arg-pred-forms (iterate inc 0))))))
Vars in clojure.contrib.mock/make-arg-checker: defn every? fn inc iterate let map true?
Used in 0 other vars

Comments top

No comments for make-arg-checker. Log in to add a comment.