diff --git a/test/manifold/deferred_test.clj b/test/manifold/deferred_test.clj index 9475afa..5677356 100644 --- a/test/manifold/deferred_test.clj +++ b/test/manifold/deferred_test.clj @@ -287,21 +287,35 @@ (deftest test-finally (let [target-d (d/deferred) d (d/deferred) - fd (d/finally - d - (fn [] - (d/success! target-d ::delivered)))] + fd (-> d + (d/finally + (fn [] + (d/success! target-d ::delivered))) + ;; to silence dropped error detection + (d/catch identity))] (d/error! d (Exception.)) (is (= ::delivered (deref target-d 0 ::not-delivered))))) (deftest test-alt (is (#{1 2 3} @(d/alt 1 2 3))) - (is (= 2 @(d/alt (d/future (Thread/sleep 10) 1) 2))) - - (is (= 2 @(d/alt (d/future (Thread/sleep 10) (throw (Exception. "boom"))) 2))) - - (is (thrown-with-msg? Exception #"boom" - @(d/alt (d/future (throw (Exception. "boom"))) (d/future (Thread/sleep 10))))) + (let [d (d/deferred) + a (d/alt d 2)] + (d/success! d 1) + (is (= 2 @a))) + + (let [d (d/deferred) + a (d/alt d 2)] + (doto d + (d/error! (Exception. "boom 1")) + ;; to silence dropped error detection + (d/catch identity)) + (is (= 2 @a))) + + (let [e (d/error-deferred (Exception. "boom 2")) + d (d/deferred) + a (d/alt e d)] + (d/success! d 1) + (is (thrown-with-msg? Exception #"boom" @a))) (testing "uniformly distributed" (let [results (atom {})