Skip to content

Commit

Permalink
Fix-up a-except
Browse files Browse the repository at this point in the history
  • Loading branch information
duey-sonian committed Jan 26, 2011
1 parent d1f5576 commit 4bd99a4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
12 changes: 10 additions & 2 deletions project.clj
@@ -1,6 +1,14 @@
(defproject conduit "0.7.0-SNAPSHOT" (defproject conduit "0.8.0"
:description "Conduit: Stream Processing in Clojure." :description "Conduit: Stream Processing in Clojure."
:dependencies [[org.clojure/clojure "1.2.0"] :dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"] [org.clojure/clojure-contrib "1.2.0"]
[arrows "1.2.0"]] [arrows "1.2.0"]
[swank-clojure "1.2.1"]]
:dev-dependencies [[swank-clojure "1.2.1"]
[org.clojars.technomancy/clj-stacktrace
"0.2.1-20101126.163600-6"]
[lein-difftest "1.3.2-20101010.033133-1"
:exclusions [clj-stacktrace]]
[lein-release "1.1.1"]
[lein-fail-fast "1.0.0"]]
:repositories {"lambda" "http://lambda.sa2s.us/snapshots/"}) :repositories {"lambda" "http://lambda.sa2s.us/snapshots/"})
32 changes: 16 additions & 16 deletions src/conduit/core.clj
Expand Up @@ -342,22 +342,22 @@
(apply a-select vp-pairs))) (apply a-select vp-pairs)))


(defn a-except [p catch-p] (defn a-except [p catch-p]
(assoc (a-comp (letfn [(a-except [f catch-f x]
{:parts (:parts p) (try
:reply (partial (fn a-except [f x] (let [[new-x new-f] (f x)]
(try [new-x (partial a-except new-f catch-f)])
(let [[new-x new-f] (f x)] (catch Exception e
[[['_ (first new-x)]] (let [[new-x new-catch] (catch-f [e x])]
(partial a-except new-f)]) [new-x (partial a-except f new-catch)]))))]
(catch Exception e {:parts (:parts p)
[[[Exception [e x]]] :reply (partial a-except
(partial a-except f)]))) (:reply p)
(:reply p))} (:reply catch-p))
(a-select :no-reply (partial a-except
Exception catch-p (:no-reply p)
'_ pass-through)) (:no-reply catch-p))
:created-by :a-except :created-by :a-except
:args [p catch-p])) :args [p catch-p]}))


(defn conduit-do [p & [v]] (defn conduit-do [p & [v]]
(a-arr (fn [x] (a-arr (fn [x]
Expand Down
18 changes: 15 additions & 3 deletions test/conduit/test_core.clj
Expand Up @@ -420,13 +420,27 @@
(let [te (a-arr (fn [x] (let [te (a-arr (fn [x]
(when (even? x) (when (even? x)
(throw (Exception. "An even int"))) (throw (Exception. "An even int")))
(* 2 x)))] (* 2 x)))
x (assoc te
:no-reply (fn this-fn [_]
[[2] this-fn])
:reply (fn this-fn [_]
[[1] this-fn]))
tx (a-except x (a-arr (constantly nil)))]
(is (thrown? Exception (is (thrown? Exception
(conduit-map te (range 5)))) (conduit-map te (range 5))))


(is (= [nil 2 nil 6 nil] (is (= [nil 2 nil 6 nil]
(conduit-map (a-except te (conduit-map (a-except te
(a-arr (constantly nil))) (a-arr (constantly nil)))
(range 5))))
(is (= (repeat 5 2)
(conduit-map tx
(range 5))))

#_(is (= []
(conduit-map (a-comp (a-all tx tx)
pass-through)
(range 5)))))) (range 5))))))


(deftest test-test-conduit (deftest test-test-conduit
Expand Down Expand Up @@ -457,5 +471,3 @@
[-1 0 1 2 3]] [-1 0 1 2 3]]
(conduit-map make-and-dec (conduit-map make-and-dec
(range 6))))) (range 6)))))

(run-tests)

0 comments on commit 4bd99a4

Please sign in to comment.