dire icon indicating copy to clipboard operation
dire copied to clipboard

Args with postconditions

Open neverfox opened this issue 8 years ago • 0 comments

The examples in the docs imply that postcondition handlers will receive args, but that doesn't seem to be the case:

(defn add-one [n]
  (inc n))

(with-postcondition! #'add-one
                     "An optional docstring."
                     ;;; Name of the postcondition
                     :not-two
                     (fn [n & args]
                       (println args)
                       (not= n 2)))

(with-handler! #'add-one
               {:postcondition :not-two}
               (fn [e result] (str "Postcondition failed for result: " result)))

(add-one 1)
nil
=> "Postcondition failed for result: 2"

Also the downstream with-handler! handler doesn't get them either, in this case.

neverfox avatar Mar 26 '16 20:03 neverfox