Assert

Testing programs can be useful. I dislike unit tests, as they force me to always create a situation to be tested from scratch. I prefer to write a test program that contains many assertions to see when the program fails, and for what reason. For this purpose, I wrote some very simple assertion macros. One asserts that an expression executes without an error and returns a true value. The other asserts that an expression really causes an error to be thrown. Both take name arguments, with which they print out nice little messages telling you how far the program already progressed.

Some example code:

(assert "Addition is commutative"
  (= (+ 2 3)
     (+ 3 2)))

(assert-fails "Dividing by zero is an error"
  (/ 5 0))

Download

The assert package depends on the error handling API of Scheme 48.