Skip to content

Commit

Permalink
Remove backward compatibility used for Clojure 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
marick committed May 8, 2013
1 parent a13f78f commit 8d73080
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 84 deletions.
4 changes: 2 additions & 2 deletions src/midje/checking/checkers/chatty.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
snd-to-last-is-as? #(= :as (second (reverse %)))
has-key-as? #(contains? % :as)]
(pred-cond arg-form
(every-pred-m vector? snd-to-last-is-as?) [arg-form (last arg-form)]
(every-pred vector? snd-to-last-is-as?) [arg-form (last arg-form)]
vector? [(-> arg-form (conj :as) (conj as-symbol)) as-symbol]
(every-pred-m map? has-key-as?) [arg-form (:as arg-form)]
(every-pred map? has-key-as?) [arg-form (:as arg-form)]
map? [(assoc arg-form :as as-symbol) as-symbol]
:else [arg-form arg-form] )))

Expand Down
2 changes: 1 addition & 1 deletion src/midje/checking/checkers/simple.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(letfn [(throwable-as-desired? [throwable desideratum]
(pred-cond desideratum
fn? (desideratum throwable)
(some-fn-m string? regex?) (extended-= (.getMessage ^Throwable throwable) desideratum)
(some-fn string? regex?) (extended-= (.getMessage ^Throwable throwable) desideratum)
class? (instance? desideratum throwable)))]

(defchecker throws
Expand Down
79 changes: 0 additions & 79 deletions src/midje/clojure/backwards_compatibility.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,82 +21,3 @@

(move-once-to-core slingshot.ex-info [ex-info ex-data])

(defn-once every-pred-m
"Takes a set of predicates and returns a function f that returns true if all of its
composing predicates return a logical true value against all of its arguments, else it returns
false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical false result against the original predicates."
{:added "1.3"}
([p]
(fn ep1
([] true)
([x] (boolean (p x)))
([x y] (boolean (and (p x) (p y))))
([x y z] (boolean (and (p x) (p y) (p z))))
([x y z & args] (boolean (and (ep1 x y z)
(every? p args))))))
([p1 p2]
(fn ep2
([] true)
([x] (boolean (and (p1 x) (p2 x))))
([x y] (boolean (and (p1 x) (p1 y) (p2 x) (p2 y))))
([x y z] (boolean (and (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z))))
([x y z & args] (boolean (and (ep2 x y z)
(every? #(and (p1 %) (p2 %)) args))))))
([p1 p2 p3]
(fn ep3
([] true)
([x] (boolean (and (p1 x) (p2 x) (p3 x))))
([x y] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y))))
([x y z] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z))))
([x y z & args] (boolean (and (ep3 x y z)
(every? #(and (p1 %) (p2 %) (p3 %)) args))))))
([p1 p2 p3 & ps]
(let [ps (list* p1 p2 p3 ps)]
(fn epn
([] true)
([x] (every? #(% x) ps))
([x y] (every? #(and (% x) (% y)) ps))
([x y z] (every? #(and (% x) (% y) (% z)) ps))
([x y z & args] (boolean (and (epn x y z)
(every? #(every? % args) ps))))))))

(defn-once some-fn-m
"Takes a set of predicates and returns a function f that returns the first logical true value
returned by one of its composing predicates against any of its arguments, else it returns
logical false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical true result against the original predicates."
{:added "1.3"}
([p]
(fn sp1
([] nil)
([x] (p x))
([x y] (or (p x) (p y)))
([x y z] (or (p x) (p y) (p z)))
([x y z & args] (or (sp1 x y z)
(some p args)))))
([p1 p2]
(fn sp2
([] nil)
([x] (or (p1 x) (p2 x)))
([x y] (or (p1 x) (p1 y) (p2 x) (p2 y)))
([x y z] (or (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z)))
([x y z & args] (or (sp2 x y z)
(some #(or (p1 %) (p2 %)) args)))))
([p1 p2 p3]
(fn sp3
([] nil)
([x] (or (p1 x) (p2 x) (p3 x)))
([x y] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y)))
([x y z] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z)))
([x y z & args] (or (sp3 x y z)
(some #(or (p1 %) (p2 %) (p3 %)) args)))))
([p1 p2 p3 & ps]
(let [ps (list* p1 p2 p3 ps)]
(fn spn
([] nil)
([x] (some #(% x) ps))
([x y] (some #(or (% x) (% y)) ps))
([x y z] (some #(or (% x) (% y) (% z)) ps))
([x y z & args] (or (spn x y z)
(some #(some % args) ps)))))))
2 changes: 1 addition & 1 deletion src/midje/parsing/util/file_position.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

(best-lineish [arrow-loc]
(try
( (some-fn-m left-lineish right-lineish #(inc (previous-lineish %))) arrow-loc)
( (some-fn left-lineish right-lineish #(inc (previous-lineish %))) arrow-loc)
(catch Throwable ex
;; `previous-lineish` returned nil: use the fallback-line-number
nil)))]
Expand Down
2 changes: 1 addition & 1 deletion src/midje/util/laziness.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[form]
(let [m #(with-meta % (meta form))]
(pred-cond form
(some-fn-m seq? list?) (m (apply list (map eagerly form)))
(some-fn seq? list?) (m (apply list (map eagerly form)))
vector? (m (vec (map eagerly form)))
map? (m (into form (map eagerly form)))
set? (m (into (empty form) (map eagerly form)))
Expand Down

0 comments on commit 8d73080

Please sign in to comment.