                                                    with-altered-roots]]
         [midje.error-handling.exceptions :only [user-error]]
         [midje.internal-ideas.wrapping :only [with-wrapping-target]]
-        [midje.ideas.arrow-symbols])
+        [midje.ideas.arrow-symbols]
+        [clojure.tools.macro :only [macrolet]])
   (:require [clojure.zip :as zip])
   (:import midje.ideas.metaconstants.Metaconstant))
 

         (= (count actual-args) (count (:arg-matchers fake)))
         (extended-list-= actual-args (:arg-matchers fake))))
  
  (defn #^:tested-private usable-default-function? [fake]
    (and (bound? (:lhs fake))
         (let [stashed-value (var-get (:lhs fake))
               unfinished-fun (:midje/unfinished-fun (meta (:lhs fake)))]
           (and (extended-fn? stashed-value)
                (or (nil? unfinished-fun)
                    (not= unfinished-fun stashed-value))))))
  
  
  (def ^:dynamic ^:private *call-action-count* (atom 0))
  
  (defn- best-call-action [function-var actual-args fakes]
    (when (= 2 @*call-action-count*)
      (throw (user-error "You seem to have created a prerequisite for"
               (str (pr-str function-var) " that interferes with that function's use in Midje's")

(defn tag-as-background-fake [fake]
  (concat fake `(:background :background :times (~'range 0))))


;;; Binding

(defn #^:tested-private usable-default-function? [fake]
  (and (bound? (:lhs fake))
    (let [stashed-value (var-get (:lhs fake))
          unfinished-fun (:midje/unfinished-fun (meta (:lhs fake)))]
      (and (extended-fn? stashed-value)
        (or (nil? unfinished-fun)
          (not= unfinished-fun stashed-value))))))

(letfn [(var-handled-by-fake? [function-var fake]
          (= function-var (:lhs fake)))]
