This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add tests for compiled flows

  • Loading branch information...
stuartsierra committed Oct 23, 2012
1 parent 93c5273 commit 4a81ca3015ce7bffd74c1922f60768a7273280a2
Showing with 30 additions and 1 deletion.
  1. +30 −1 test/com/stuartsierra/flow_test.clj
@@ -22,18 +22,36 @@
(def f3
(assoc f1 :c (flow-fn [a b] (+ 1000 a b))))
+(def f1-ab-all (compile f1 [:a :b]))
+(def f1-ab-c (compile f1 [:a :b] [:c]))
+(def f1-ab-cd (compile f1 [:a :b] [:c :d]))
+(def f2-ab-all (compile f2 [:a :b]))
+(def f3-ab-all (compile f3 [:a :b]))
+
(deftest run-complete
(is (= {:f 7 :e 6, :c 3, :d 3, :a 1, :b 2}
(run f1 {:a 1 :b 2}))))
+(deftest compiled-complete
+ (is (= {:f 7 :e 6, :c 3, :d 3, :a 1, :b 2}
+ (f1-ab-all {:a 1 :b 2}))))
+
(deftest run-partial-1
(is (= {:c 3, :a 1, :b 2}
(run f1 {:a 1 :b 2} [:c]))))
+(deftest compiled-partial-1
+ (is (= {:c 3, :a 1, :b 2}
+ (f1-ab-c {:a 1 :b 2}))))
+
(deftest run-partial-2
(is (= {:c 3, :d 3, :a 1, :b 2}
(run f1 {:a 1 :b 2} [:c :d]))))
+(deftest compiled-partial-2
+ (is (= {:c 3, :d 3, :a 1, :b 2}
+ (f1-ab-cd {:a 1 :b 2}))))
+
(deftest run-partial-provided-input
(is (= {:a 1, :b 2}
(run f1 {:a 1 :b 2} [:b]))))
@@ -45,10 +63,21 @@
(deftest run-missing
(is (thrown? Exception (run f1 {:a 1} [:d]))))
+(deftest compiled-missing
+ (is (thrown? Exception (f1-ab-all {:a 1}))))
+
(deftest run-const
(is (= {:f 7 :e 103, :c 100, :d 3, :a 1, :b 2}
(run f2 {:a 1 :b 2}))))
+(deftest compiled-const
+ (is (= {:f 7 :e 103, :c 100, :d 3, :a 1, :b 2}
+ (f2-ab-all {:a 1 :b 2}))))
+
(deftest run-modified
(is (= {:f 7 :e 1006, :c 1003, :d 3, :a 1, :b 2}
- (run f3 {:a 1 :b 2}))))
+ (run f3 {:a 1 :b 2}))))
+
+(deftest compiled-modified
+ (is (= {:f 7 :e 1006, :c 1003, :d 3, :a 1, :b 2}
+ (f3-ab-all {:a 1 :b 2}))))

0 comments on commit 4a81ca3

Please sign in to comment.