dimanche 24 janvier 2016

How can one implement the (with-test..) macro in ClojureScript?

Pure clojure has the with-test macro. ClojureScript does not. This means that -- in ClojureScript -- you can't couple a test and a function within one construct (something that seems useful in a developer environment). That is, you can't do something like the following:

(with-test
    (defn my-function [x y]
      (+ x y))
  (is (= 4 (my-function 2 2)))
  (is (= 7 (my-function 3 4))))

(test #'my-function) 

The popular package cemerick/clojurescript.test had its own implementation of with-test, but that package has been deprecated in favor of lein doo.

Question: How can one implement with-test in ClojureScript (preferably in a way that is compatible with lein doo)?

Aucun commentaire:

Enregistrer un commentaire