Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Renaming the attach-to-producer and attach-to-consumer

Now they are going to have the minimalistic names p* and *c
  • Loading branch information...
commit ba3b7669aa26956d38ed8e9a13cd800f71374246 1 parent 7ba4059
@roman authored
Showing with 31 additions and 31 deletions.
  1. +3 −3 src/river/core.clj
  2. +28 −28 test/river/test/seq.clj
View
6 src/river/core.clj
@@ -158,7 +158,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-;; Filters
+;; Filter functions
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -217,7 +217,7 @@
(ensure-inner-done (partial outer-consumer consumer0*)
inner-consumer))))
-(defn attach-to-consumer
+(defn *c
"..."
[consumer some-filter]
(letfn [
@@ -233,7 +233,7 @@
result (check inner-consumer)]
result)))
-(defn attach-to-producer
+(defn p*
"..."
[producer some-filter]
(fn new-producer [consumer]
View
56 test/river/test/seq.clj
@@ -104,16 +104,16 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest mapcat*-test
- (let [new-consumer (attach-to-consumer rs/consume
- (rs/mapcat* #(vector % %)))
+ (let [new-consumer (*c rs/consume
+ (rs/mapcat* #(vector % %)))
result (run (rs/produce-seq 7 (range 1 4))
new-consumer)]
(is (= [1 1 2 2 3 3] (:result result)))
(is (= eof (:remainder result)))))
(deftest map*-test
- (let [new-producer (attach-to-producer (rs/produce-seq 7 (range 1 10))
- (rs/map* #(+ % 10)))
+ (let [new-producer (p* (rs/produce-seq 7 (range 1 10))
+ (rs/map* #(+ % 10)))
result (run new-producer
rs/consume)]
(is (= (range 11 20) (:result result)))
@@ -121,8 +121,8 @@
(deftest filter*-test
- (let [new-consumer (attach-to-consumer (rs/take 5)
- (rs/filter* #(= 0 (mod % 2))))
+ (let [new-consumer (*c (rs/take 5)
+ (rs/filter* #(= 0 (mod % 2))))
result (run (rs/produce-seq (range 0 11))
new-consumer)]
(is (= [0 2 4 6 8] (:result result)))
@@ -139,8 +139,8 @@
(deftest drop-while*-test
- (let [new-producer (attach-to-producer (rs/produce-seq 6 (range 1 20))
- (rs/drop-while* not-fizzbuzz))
+ (let [new-producer (p* (rs/produce-seq 6 (range 1 20))
+ (rs/drop-while* not-fizzbuzz))
result (run new-producer
rs/first)]
(is (= 15 (:result result)))
@@ -148,56 +148,56 @@
(deftest isolate*-test
- (let [new-consumer (attach-to-consumer rs/consume (rs/isolate* 5))
+ (let [new-consumer (*c rs/consume
+ (rs/isolate* 5))
result (run (rs/produce-seq 7 (range 1 10000))
new-consumer)]
(is (= (range 1 6) (:result result)))
(is (= [6 7] (:remainder result)))))
(deftest isolate*-with-less-than-needed
- (let [new-producer (attach-to-producer
- (rs/produce-seq 1 (range 1 4))
- (rs/isolate* 5))
+ (let [new-producer (p* (rs/produce-seq 1 (range 1 4))
+ (rs/isolate* 5))
result (run new-producer
rs/consume)]
(is (= [1 2 3] (:result result)))
(is (= eof (:remainder result)))))
(deftest require*-test
- (let [new-producer (attach-to-producer (rs/produce-seq 2 (range 1 8))
- (rs/require* 8))]
+ (let [new-producer (p* (rs/produce-seq 2 (range 1 8))
+ (rs/require* 8))]
(is (thrown-with-msg? Exception #"require*"
(run new-producer
rs/consume))))
- (let [new-consumer (attach-to-consumer rs/consume
- (rs/require* 8))]
+ (let [new-consumer (*c rs/consume
+ (rs/require* 8))]
(is (thrown-with-msg? Exception #"require*"
(run (rs/produce-seq 2 (range 1 8))
new-consumer)))))
(deftest require*-with-more-than-needed-test
- (let [new-producer (attach-to-producer (rs/produce-seq (range 1 8))
- (rs/require* 1))
+ (let [new-producer (p* (rs/produce-seq (range 1 8))
+ (rs/require* 1))
result (run new-producer
rs/consume)]
(is (yield? result))
(is (= [1 2 3 4 5 6 7] (:result result))))
- (let [new-consumer (attach-to-consumer rs/consume
- (rs/require* 1))
+ (let [new-consumer (*c rs/consume
+ (rs/require* 1))
result (run (rs/produce-seq (range 1 8))
new-consumer)]
(is (yield? result))
(is (= [1 2 3 4 5 6 7] (:result result)))))
(deftest stream-while*-test
- (let [new-producer (attach-to-producer (rs/produce-seq 10 (range 1 20))
- (rs/stream-while* not-fizzbuzz))
+ (let [new-producer (p* (rs/produce-seq 10 (range 1 20))
+ (rs/stream-while* not-fizzbuzz))
result (run new-producer
rs/consume)]
(is (= (range 1 15) (:result result)))
(is (range 15 20) (:remainder result)))
- (let [new-consumer (attach-to-consumer rs/consume
- (rs/stream-while* not-fizzbuzz))
+ (let [new-consumer (*c rs/consume
+ (rs/stream-while* not-fizzbuzz))
result (run (rs/produce-seq 10 (range 1 20))
new-consumer)]
(is (= (range 1 15) (:result result)))
@@ -205,14 +205,14 @@
(deftest split-when*-test
- (let [new-producer (attach-to-producer (rs/produce-seq 10 (range 1 12))
- (rs/split-when* #(= 0 (mod % 3))))
+ (let [new-producer (p* (rs/produce-seq 10 (range 1 12))
+ (rs/split-when* #(= 0 (mod % 3))))
result (run new-producer
rs/consume)]
(is (= [[1 2 3] [4 5 6] [7 8 9] [10 11]] (:result result)))
(is eof (:remainder result)))
- (let [new-consumer (attach-to-consumer rs/consume
- (rs/split-when* #(= 0 (mod % 3))))
+ (let [new-consumer (*c rs/consume
+ (rs/split-when* #(= 0 (mod % 3))))
result (run (rs/produce-seq 10 (range 1 12))
new-consumer)]
(is (= [[1 2 3] [4 5 6] [7 8 9] [10 11]] (:result result)))
Please sign in to comment.
Something went wrong with that request. Please try again.