Skip to content

Instantly share code, notes, and snippets.

@chr15m
Created August 29, 2019 05:46
Show Gist options
  • Save chr15m/34b8150049e3f8e3c3d013aa1d97075e to your computer and use it in GitHub Desktop.
Save chr15m/34b8150049e3f8e3c3d013aa1d97075e to your computer and use it in GitHub Desktop.
Hy testing microframework
; *** Test harness
; Note: works in Hy 0.11.1 - needs to be upgraded for recent Hy
(defn print-expression [expr]
(+ "(" (.join " " (list-comp (cond [(= (type x) HyExpression) (print-expression x)]
[(= (type x) HyString) (+ "\"" x "\"")]
[True (str x)]) [x expr])) ")"))
(defmacro test-case [expr]
(quasiquote (do
(print (+ "Test: \t" (unquote (print-expression expr))))
(unquote expr)
(print "Pass:\t✔"))))
; *** example usage
(test-case (assert (= 42 42)))
(test-case (assert (= 42 43)))
(test-case (assert (= (this-symbol-is-not-defined) true)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment