hyperfiddle / rcf

RCF – a REPL-first, async test macro for Clojure/Script
MIT License
270 stars 11 forks source link

Sequential rewriting broken in cljs #56

Open ggeoffrey opened 1 year ago

ggeoffrey commented 1 year ago

Cljs macroexpansion needs to sequence test steps using a continuation passing style (we cannot block on a js runtime) Current rewriting does not sequence steps correctly, the problem is exhibited by rcf/with.

dustingetz commented 1 year ago

Workaround:

(defmacro with
  "Resource cleanup helper, based on missionary's dependency-free Task protocol, see https://github.com/leonoel/task"
  [dispose-fn & body]
  `(let [dispose# ~dispose-fn
         #_#_res# (do ~@body)]    ; busted, introduces second rewrite pass - see https://github.com/hyperfiddle/rcf/issues/56
     ~@body
     (dispose#) ; workaround - due to async dependency on body, must be in same RCF rewrite pass
     #_res#))