Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix-up a-except

  • Loading branch information...
commit 4bd99a4b68b3b3cd0aa18ffa3841afe4486d0a9e 1 parent d1f5576
@duey-sonian duey-sonian authored
Showing with 41 additions and 21 deletions.
  1. +10 −2 project.clj
  2. +16 −16 src/conduit/core.clj
  3. +15 −3 test/conduit/test_core.clj
View
12 project.clj
@@ -1,6 +1,14 @@
-(defproject conduit "0.7.0-SNAPSHOT"
+(defproject conduit "0.8.0"
:description "Conduit: Stream Processing in Clojure."
:dependencies [[org.clojure/clojure "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/"})
View
32 src/conduit/core.clj
@@ -342,22 +342,22 @@
(apply a-select vp-pairs)))
(defn a-except [p catch-p]
- (assoc (a-comp
- {:parts (:parts p)
- :reply (partial (fn a-except [f x]
- (try
- (let [[new-x new-f] (f x)]
- [[['_ (first new-x)]]
- (partial a-except new-f)])
- (catch Exception e
- [[[Exception [e x]]]
- (partial a-except f)])))
- (:reply p))}
- (a-select
- Exception catch-p
- '_ pass-through))
- :created-by :a-except
- :args [p catch-p]))
+ (letfn [(a-except [f catch-f x]
+ (try
+ (let [[new-x new-f] (f x)]
+ [new-x (partial a-except new-f catch-f)])
+ (catch Exception e
+ (let [[new-x new-catch] (catch-f [e x])]
+ [new-x (partial a-except f new-catch)]))))]
+ {:parts (:parts p)
+ :reply (partial a-except
+ (:reply p)
+ (:reply catch-p))
+ :no-reply (partial a-except
+ (:no-reply p)
+ (:no-reply catch-p))
+ :created-by :a-except
+ :args [p catch-p]}))
(defn conduit-do [p & [v]]
(a-arr (fn [x]
View
18 test/conduit/test_core.clj
@@ -420,13 +420,27 @@
(let [te (a-arr (fn [x]
(when (even? x)
(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
(conduit-map te (range 5))))
(is (= [nil 2 nil 6 nil]
(conduit-map (a-except te
(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))))))
(deftest test-test-conduit
@@ -457,5 +471,3 @@
[-1 0 1 2 3]]
(conduit-map make-and-dec
(range 6)))))
-
-(run-tests)
Please sign in to comment.
Something went wrong with that request. Please try again.