Created
July 5, 2020 22:44
-
-
Save sam-falvo/247d45a896cc6aae82baf36f8bd1456a to your computer and use it in GitHub Desktop.
My home-brew unit test system for my Equilibrium-cl game, since none of the other CL unit test systems I've tried satisfy my expectations. FiveAM, for example, eats console output (including compiler warnings and errors!) and appears to auto-define (misspelled) special variables without my consent. This is a no-bullshit testing system.
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
(defun expand-test (name actual-expr fn expected-expr setup-form teardown-form) | |
`(progn | |
(defun ,name () | |
(unwind-protect | |
(progn | |
,setup-form | |
(let ((expected ,expected-expr) | |
(actual ,actual-expr)) | |
(unless (,fn actual expected) | |
(error "~A: Expected ~A; got ~A" (string ',name) expected actual)))) | |
,teardown-form)) | |
(,name))) | |
(defmacro test (name expected-expr fn actual-expr &key setup teardown) | |
(expand-test name expected-expr fn actual-expr setup teardown)) | |
(test viewables-must-be-empty | |
eq:*viewables* eql nil | |
:setup (progn | |
(setf eq:*viewables* '(1 2 3)) | |
(eq:hide-everything) ; should set *viewables* to NIL | |
(format t "SETUP!~%")) | |
:teardown (format t "TEARDOWN!~%")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment