Think I’ve found a bug in core.async tests, the following test for mult working seems purely coincidental:
;; ASYNC-127
(let [ch (to-chan! [1 2 3])
m (mult ch)
t-1 (chan)
t-2 (chan)
t-3 (chan)]
(tap m t-1)
(tap m t-2)
(tap m t-3)
(close! t-3)
(is (= 1 (<!! t-1)))
(is (= nil (a/poll! t-1))) ;; t-2 hasn't taken yet
(is (= 1 (<!! t-2)))
(is (= 2 (<!! t-1))) ;; now available
(is (= nil (a/poll! t-1)))))
The docstring of core.async/mult states that: Items received when there are no taps get dropped. Following this statement, the 3 items put by to-chan! should be dropped, as when the mult is created, it would start consuming them without taps yet on the http://mult.My suspicion is that it passes because the go’s created inside mult and to-chan! might be slow enough to create so that the taps get executed before the mult starts consuming.
Does this make sense? Am I missing something?Logged in https://ask.clojure.org/index.php/12100/core-async-mult-test-is-passing-accidentally
possibly. I don't have time to look at it right now, but if you want to put it on https://ask.clojure.org, I will look at it eventually