Ch1 Notes

The is the code that I recommend at the start of each file. The first line sets the debug level to maximum, and the last three load the “check-expect” system and set it to print out details about every failure.

(declaim (optimize (debug 3)))
(ql:quickload :lisp-unit)
(use-package :lisp-unit)
(defparameter *print-failures* t)

Unit tests

Defining tests follows the pattern below.

(define-test test-addition
  "Test the basic addition function. Duh."
  (assert-equal 5 (+ 2 3))
  (assert-equal 8 (+ 10 -2)))

There is a complete writeup of lisp-unit on GitHub, including advanced features like tagging tests and only running some of them.

Running tests

Just call run-tests at the end of your file.

(run-tests)

Lisp Functions

Emacs Shortcuts

These are the shortcuts I regularly use:

Occasionally I need this one to reset a messed up state (remember the lisp interpreter does not restart between times when you load files).