Linked by Eugenia Loli-Queru on Fri 13th Jul 2007 06:17 UTC, submitted by IdaAshley
Thread beginning with comment 255216
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.





Member since:
2005-07-06
It can be! It's a 20-minute exercise to come up with some macros that let you define unit tests in Lisp code. Moreover, since the compiler fully evaluates top-level calls at compile-time, you can do stuff like:
; trees.lisp
(defun make-tree () ... ) ; make a tree
(defun add-to-tree (something tree) ...) ; add stuff to a tree
; more implementation
; this is a simple macro to write!
(define-unit-test some-test
(add-to-tree 5 (make-tree)))
; need more complete test!
(run-tests) ; run the tests at compile-time
This way, every time you compile the file, the compiler will execute (run-tests), and you'll get a compile-time error if your change broke any of the unit tests.
Edited 2007-07-13 13:07