Skip to content

Commit

Permalink
use condp instead of lookup in a map
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBaranosky committed Apr 29, 2012
1 parent f97b9bb commit 3f9010f
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/midje/semi_sweet.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
;; FURTHERMORE, I wanted to use set operations to check for fake and not-called,
;; but those fail for reasons I don't understand. Bah.
(defn- ^{:testable true } check-for-arrow [arrow]
(get {=> :check-match
=expands-to=> :check-match
=not=> :check-negated-match
=deny=> :check-negated-match} (name arrow)))
(condp = (name arrow)
=> :check-match
=expands-to=> :check-match
=not=> :check-negated-match
=deny=> :check-negated-match))

(defmacro unprocessed-check
"Creates a map that contains a function-ized version of the form being
Expand All @@ -54,17 +55,15 @@
:arrow '~arrow }
(hash-map-duplicates-ok ~@overrides)))

(letfn [(how-to-handle-check [_call-form_ arrow & _]
(get {=> :expect*
=not=> :expect*
=deny=> :expect*
=expands-to=> :expect-macro*
=future=> :report-future-fact} (name arrow)))]
(defmulti ^{:private true} expect-expansion (fn [_call-form_ arrow & _]
(condp = (name arrow)
=> :expect*
=not=> :expect*
=deny=> :expect*
=expands-to=> :expect-macro*
=future=> :report-future-fact )))

(defmulti ^{:private true} expect-expansion how-to-handle-check))

(defmethod expect-expansion :expect*
[call-form arrow expected-result fakes overrides]
(defmethod expect-expansion :expect* [call-form arrow expected-result fakes overrides]
`(let [check# (unprocessed-check ~call-form ~arrow ~expected-result ~overrides)]
(midje.semi-sweet/*expect-checking-fn* check# ~fakes)))

Expand Down

0 comments on commit 3f9010f

Please sign in to comment.