Skip to content

Instantly share code, notes, and snippets.

@bhb
Created March 22, 2017 21:13
Show Gist options
  • Save bhb/4bd1897b0f5c761ed9782dae038819dd to your computer and use it in GitHub Desktop.
Save bhb/4bd1897b0f5c761ed9782dae038819dd to your computer and use it in GitHub Desktop.
Trying to bugs in core.async tests
(ns my-project.example-test
(:require
[cljs.core.async :refer [<! >! chan close! to-chan]]
[cljs.test :refer [async is deftest testing use-fixtures]]
[cljs.core.async :as async :refer [timeout]]
[cljs.core.async.impl.timers :as async.timers]
[cljs.core.async.impl.dispatch :as async.dispatch])
(:require-macros [cljs.core.async.macros :refer [go]]))
(def check-async-status
{:after (fn []
(async done
(js/setTimeout
(fn []
(prn {:task-count (.-length async.dispatch/tasks)
:running? async.dispatch/running?
:queued? async.dispatch/queued?
:timeouts-map async.timers/timeouts-map
})
(done))
1)))})
(use-fixtures :each check-async-status)
;; This test has a bug (reading from a channel that is always empty)
;; Is there a way to automatically detect this in a test fixture?
(deftest fake-test
(async done
(prn "starting test")
(async/take! (async/chan)
(fn [item]
(prn "This will never run")))
(prn "about to call 'done'")
(done)))
;; {:task-count 0, :running? false, :queued? false, :timeouts-map {}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment