Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active February 15, 2016 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfikes/4e9e78753a0d406da873 to your computer and use it in GitHub Desktop.
Save mfikes/4e9e78753a0d406da873 to your computer and use it in GitHub Desktop.
cljs.test for bootstrap
  • The cljs.test/is macro calls cljs.test/try-expr macro in the same compilation stage. While this can be done in Clojure, it can't be done in ClojureScript where macros must be defined in a different stage than consumed. The fix is to build a tower (and the functions used by the macro at the top of that tower—function?, assert-predicate, etc.—can be moved to be there). (See http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html)
  • The cljs.test macros make use of the cljs.analyzer.api Clojure namespace. The few needed functions can be copied over into a ClojureScript namespace.
  • The cljs.test macros make use of Clojure code in the clojure.template namespace. Solved by copying to ClojureScript namespaces.
  • There is some code in the deftest macro that, in Clojure makes use of var in a dynamic fashion. I updated this to make use of Planck's eval capability to evaluate the same var form at runtime. I also associated the vars with the deftest symbols in a different way than the original implementation, keeping a map in an atom.
  • There were a few spots that threw IllegalArgumentException or Exception. Converted to make exceptions using ex-info.
  • The entire commit is here https://github.com/mfikes/planck/commit/21dddf244030cae1917fd735513fb8b5adb8409f
  • I found that I had to make use of :static-fns to load (and AOT compile) the resulting cljs.test macros in order to work around the perf bug mentioned here http://blog.fikesfarm.com/posts/2015-11-03-planck-static-function-dispatch.html otherwise it would actually crash JavaScriptCore

Note, the use of Planck's eval is not necessary, see https://github.com/mfikes/planck/commit/bed0734a5177fbfcc964a5f9763a8b6007141e2f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment