Created
August 29, 2019 05:46
-
-
Save chr15m/34b8150049e3f8e3c3d013aa1d97075e to your computer and use it in GitHub Desktop.
Hy testing microframework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; *** 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