Skip to content

Commit

Permalink
[i/items] items & item-ps cancel after done
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurC committed Aug 29, 2024
1 parent 4ec2e38 commit 57a4371
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/hyperfiddle/incseq/items_eager_impl_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,22 @@
_ (q ::none)
_ (t/is (= ::none (q)))]))

(t/deftest cancel-after-done
(let [q (->mq)
_ (q (assoc (d/empty-diff 1) :grow 1 :change {0 :foo})) ; what input will return on transfer
items (spawn-ps q)
[_in-step _in-done] (q)
_ (t/is (= :items-step (q)))
_diff @items
_ (items)
_ (t/is (= :input-cancel (q)))
_ (t/is (= :items-step (q)))
_ (t/is (thrown? Cancelled @items))
_ (t/is (= :items-done (q)))
_ (items)
_ (q ::none)
_ (t/is (= ::none (q)))]))

(t/deftest item-ps-double-cancellation-idle
(let [q (->mq)
_ (q (assoc (d/empty-diff 1) :grow 1 :change {0 :foo})) ; what input will return on transfer
Expand Down Expand Up @@ -543,6 +559,25 @@
_ (q ::none)
_ (t/is (= ::none (q)))]))

(t/deftest item-ps-cancel-after-done
(let [q (->mq)
_ (q (assoc (d/empty-diff 1) :grow 1 :change {0 :foo})) ; what input will return on transfer
items (spawn-ps q)
[_in-step _in-done] (q)
_ (t/is (= :items-step (q)))
diff @items
_ (t/is (= (assoc (d/empty-diff 1) :grow 1) (assoc diff :change {})))
item0 ((-> diff :change (get 0)) #(q :item0-step) #(q :item0-done))
_ (t/is (= :item0-step (q)))
_ (t/is (= :foo @item0))
_ (item0)
_ (t/is (= :item0-step (q)))
_ (t/is (thrown? Cancelled @item0))
_ (t/is (= :item0-done (q)))
_ (item0)
_ (q ::none)
_ (t/is (= ::none (q)))]))

;; missing tests
;; - double cancel before termination
;; - dead-item-ps
Expand Down

0 comments on commit 57a4371

Please sign in to comment.