Skip to content

Instantly share code, notes, and snippets.

@yanatan16
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanatan16/9bb640e92be2b1fa4c7c to your computer and use it in GitHub Desktop.
Save yanatan16/9bb640e92be2b1fa4c7c to your computer and use it in GitHub Desktop.
tap doesnt work for the second channel if already closed
(require '[clojure.core.async :refer (<!! >!! close! chan mult tap alt!! timeout)])
(defn assert-closed! [c m] (assert (= nil (alt!! c ([v] v) (timeout 50) ([_] :timeout))) m))
(let [[c1 c2 c3] (repeatedly 3 chan)
_ (close! c1)
m (mult c1)]
(tap m c2)
(<!! (timeout 50))
(tap m c3)
(<!! (timeout 50))
(assert-closed! c1 "c1 sanity")
(assert-closed! c1 "c2 should")
(assert-closed! c3 "c3 test") ; So this assert fails because tap doesn't check to see if mult-source is already closed.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment