Skip to content

Commit e592c1d

Browse files
committed
updated tests, bumped up version
1 parent 221fad4 commit e592c1d

File tree

2 files changed

+49
-37
lines changed

2 files changed

+49
-37
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject domino/core "0.3.2"
1+
(defproject domino/core "0.3.3"
22
:description "Clojure(script) data flow engine"
33
:url "https://github.com/domino-clj/domino"
44
:license {:name "Eclipse Public License"

test/domino/events_test.cljc

+48-36
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
(test-graph-events
4242
[]
4343
[[[:a] 1]]
44-
{::core/db (assoc default-db :a 1)
44+
{::core/db (assoc default-db :a 1)
4545
::core/change-history [[[:a] 1]]}))
4646

4747
(deftest nil-output-ignored
@@ -50,7 +50,7 @@
5050
:outputs [[:b]]
5151
:handler (fn [_ _ _])}]
5252
[[[:a] 1]]
53-
{::core/db (assoc default-db :a 1)
53+
{::core/db (assoc default-db :a 1)
5454
::core/change-history [[[:a] 1]]}))
5555

5656
(deftest single-input-output
@@ -59,7 +59,7 @@
5959
:outputs [[:b]]
6060
:handler (fn [ctx {:keys [a]} {:keys [b]}] {:b (+ a b)})}]
6161
[[[:a] 1]]
62-
{::core/db (assoc default-db :a 1 :b 1)
62+
{::core/db (assoc default-db :a 1 :b 1)
6363
::core/change-history [[[:a] 1] [[:b] 1]]}))
6464

6565
(deftest unmatched-event
@@ -68,7 +68,7 @@
6868
:outputs [[:b]]
6969
:handler (fn [ctx _ _] {:b 5})}]
7070
[[[:c] 1]]
71-
{::core/db (assoc default-db :c 1)
71+
{::core/db (assoc default-db :c 1)
7272
::core/change-history [[[:c] 1]]}))
7373

7474
(deftest nil-value
@@ -77,9 +77,21 @@
7777
:outputs [[:b]]
7878
:handler (fn [_ _ _] {:b nil})}]
7979
[[[:a] 1]]
80-
{::core/db (assoc default-db :a 1 :b nil)
80+
{::core/db (assoc default-db :a 1 :b nil)
8181
::core/change-history [[[:a] 1] [[:b] nil]]}))
8282

83+
(deftest output-dependent-event
84+
(test-graph-events
85+
[{:inputs [[:a] [:b]]
86+
:outputs [[:c]]
87+
:handler (fn [_ {:keys [a b]} _] {:c (+ a b)})}
88+
{:inputs [[:a] [:c]]
89+
:outputs [[:d]]
90+
:handler (fn [_ {:keys [a c]} _] {:d (+ a c)})}]
91+
[[[:a] 1]]
92+
{::core/db (assoc default-db :a 1 :c 1 :d 2)
93+
::core/change-history [[[:a] 1] [[:c] 1] [[:d] 1] [[:d] 2]]}))
94+
8395
(deftest exception-bubbles-up
8496
(is
8597
(thrown?
@@ -100,7 +112,7 @@
100112
:outputs [[:b]]
101113
:handler (fn [ctx {:keys [a]} {:keys [b]}] {:b (inc a)})}]
102114
[[[:a] 0]]
103-
{::core/db (assoc default-db :b 1)
115+
{::core/db (assoc default-db :b 1)
104116
::core/change-history [[[:a] 0] [[:b] 1]]}))
105117

106118
(deftest same-input-as-output
@@ -109,9 +121,9 @@
109121
:outputs [[:a]]
110122
:handler (fn [ctx {:keys [a]} _] {:a (inc a)})}]
111123
[[[:a] 1]]
112-
{::core/db (assoc default-db :a 2)
124+
{::core/db (assoc default-db :a 2)
113125
::core/change-history [[[:a] 1]
114-
[[:a] 2]]}))
126+
[[:a] 2]]}))
115127

116128
(deftest cyclic-inputs
117129
(test-graph-events
@@ -122,10 +134,10 @@
122134
:outputs [[:a]]
123135
:handler (fn [ctx {:keys [b]} {:keys [a]}] {:a (inc a)})}]
124136
[[[:a] 1]]
125-
{::core/db (assoc default-db :b 1 :a 2)
137+
{::core/db (assoc default-db :b 1 :a 2)
126138
::core/change-history [[[:a] 1]
127-
[[:b] 1]
128-
[[:a] 2]]})
139+
[[:b] 1]
140+
[[:a] 2]]})
129141
(test-graph-events
130142
[{:inputs [[:a]]
131143
:outputs [[:b] [:c]]
@@ -134,11 +146,11 @@
134146
:outputs [[:a]]
135147
:handler (fn [ctx {:keys [b]} {:keys [a]}] {:a (+ b a)})}]
136148
[[[:a] 1] [[:b] 2]]
137-
{::core/db (assoc default-db :b 3 :a 4)
149+
{::core/db (assoc default-db :b 3 :a 4)
138150
::core/change-history [[[:a] 1]
139-
[[:b] 2]
140-
[[:b] 3]
141-
[[:a] 4]]}))
151+
[[:b] 2]
152+
[[:b] 3]
153+
[[:a] 4]]}))
142154

143155
(deftest test-cascading-events
144156
(test-graph-events
@@ -149,20 +161,20 @@
149161
:outputs [[:d]]
150162
:handler (fn [ctx {:keys [c]} _] {:d (inc c)})}]
151163
[[[:a] 1] [[:b] 1]]
152-
{::core/db (assoc default-db :a 1 :b 2 :c 1 :d 2)
164+
{::core/db (assoc default-db :a 1 :b 2 :c 1 :d 2)
153165
::core/change-history [[[:a] 1]
154-
[[:b] 1]
155-
[[:b] 2]
156-
[[:c] 1]
157-
[[:d] 2]]}))
166+
[[:b] 1]
167+
[[:b] 2]
168+
[[:c] 1]
169+
[[:d] 2]]}))
158170

159171
(deftest multi-input-event
160172
(test-graph-events
161173
[{:inputs [[:a] [:b]]
162174
:outputs [[:c]]
163175
:handler (fn [ctx {:keys [a b]} {:keys [c]}] {:c (+ a b)})}]
164176
[[[:a] 1] [[:b] 1]]
165-
{::core/db (assoc default-db :a 1 :b 1 :c 2)
177+
{::core/db (assoc default-db :a 1 :b 1 :c 2)
166178
::core/change-history [[[:a] 1] [[:b] 1] [[:c] 2]]}))
167179

168180
(deftest multi-output-event
@@ -171,30 +183,30 @@
171183
:outputs [[:b] [:c]]
172184
:handler (fn [ctx {:keys [a]} {:keys [b c]}] {:b (+ a b) :c (inc c)})}]
173185
[[[:a] 1]]
174-
{::core/db (assoc default-db :a 1 :b 1 :c 1)
186+
{::core/db (assoc default-db :a 1 :b 1 :c 1)
175187
::core/change-history [[[:a] 1] [[:b] 1] [[:c] 1]]}))
176188

177189
(deftest multi-input-output-event-omitted-unchanged-results
178190
(test-graph-events
179191
[{:inputs [[:a] [:b]]
180-
:outputs [[:b] [:c] [:d]]
181-
:handler (fn [ctx {:keys [a b]} _] {:b (+ a b)})}]
192+
:outputs [[:c] [:d] [:e]]
193+
:handler (fn [ctx {:keys [a b]} _] {:c (+ a b)})}]
182194
[[[:a] 1] [[:b] 1]]
183-
{::core/db (assoc default-db :a 1 :b 2)
195+
{::core/db (assoc default-db :a 1 :b 1 :c 2)
184196
::core/change-history [[[:a] 1]
185-
[[:b] 1]
186-
[[:b] 2]]}))
197+
[[:b] 1]
198+
[[:c] 2]]}))
187199

188200
(deftest multi-input-output-event
189201
(test-graph-events
190202
[{:inputs [[:a] [:b]]
191-
:outputs [[:b] [:c] [:d]]
192-
:handler (fn [ctx {:keys [a b]} {:keys [c d]}] {:b (+ a b) :c c :d d})}]
203+
:outputs [[:c] [:d] [:e]]
204+
:handler (fn [ctx {:keys [a b]} {:keys [d e]}] {:c (+ a b) :d d :e e})}]
193205
[[[:a] 1] [[:b] 1]]
194-
{::core/db (assoc default-db :a 1 :b 2)
206+
{::core/db (assoc default-db :a 1 :c 2 :b 1)
195207
::core/change-history [[[:a] 1]
196-
[[:b] 1]
197-
[[:b] 2]]}))
208+
[[:b] 1]
209+
[[:c] 2]]}))
198210

199211
(deftest unrelated-events
200212
(test-graph-events
@@ -205,7 +217,7 @@
205217
:outputs [[:d]]
206218
:handler (fn [ctx {:keys [c]} _] {:d (dec c)})}]
207219
[[[:a] 1]]
208-
{::core/db (assoc default-db :a 1 :b 2)
220+
{::core/db (assoc default-db :a 1 :b 2)
209221
::core/change-history [[[:a] 1] [[:b] 2]]}))
210222

211223
(deftest context-access
@@ -216,7 +228,7 @@
216228
:outputs [[:b]]
217229
:handler (fn [ctx {:keys [a]} _] {:b ((:action ctx) a)})}]
218230
[[[:a] 1]]
219-
{::core/db (assoc default-db :a 1 :b 6)
231+
{::core/db (assoc default-db :a 1 :b 6)
220232
::core/change-history [[[:a] 1] [[:b] 6]]}))
221233

222234
(deftest triggering-sub-path
@@ -226,6 +238,6 @@
226238
:handler (fn [ctx {h :h} {old-h :h}]
227239
{:h (update old-h :i + (:i h))})}]
228240
[[[:h :i] 1]] ;; [[[:h] {:i 2}]]
229-
{::core/db (assoc default-db :h {:i 2})
241+
{::core/db (assoc default-db :h {:i 2})
230242
::core/change-history [[[:h :i] 1]
231-
[[:h] {:i 2}]]}))
243+
[[:h] {:i 2}]]}))

0 commit comments

Comments
 (0)