Skip to content

Commit

Permalink
[Issue #82] pulled duplicated code into private fn
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBaranosky committed Mar 11, 2012
1 parent b835d32 commit 8a81916
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/midje/ideas/formulas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@

(defn shrink [& _args] [])

(defn- formula-fact [docstring body]
`(midje.sweet/fact ~docstring
~@body :formula :formula-in-progress))

(defmacro shrink-failure-case [docstring binding-name failed-binding-val body]
`(loop [[cur-shrunk# & rest#] (midje.ideas.formulas/shrink ~failed-binding-val)]
(when cur-shrunk#
(when (let [~binding-name cur-shrunk#]
(midje.sweet/fact ~docstring ;; duplicated
~@body :formula :formula-in-progress))
~(formula-fact docstring body))
(recur rest#)))))

(defmacro formula
Expand All @@ -42,8 +45,7 @@
[& args]
(when-valid &form
(let [[docstring? [bindings & body]] (pop-docstring args)
fact `(midje.sweet/fact ~docstring? ;; duplicated
~@body :formula :formula-in-progress )
fact (formula-fact docstring? body)
conclusion-signal `(midje.sweet/fact
:always-pass midje.sweet/=> :always-pass :formula :formula-conclude )]

Expand Down

0 comments on commit 8a81916

Please sign in to comment.