Merge pull request #136 from orodley/source-changes
[jscl.git] / tests.lisp
1 (defparameter *total-tests* 0)
2 (defparameter *passed-tests* 0)
3 (defparameter *failed-tests* 0)
4 (defparameter *expected-failures* 0)
5 (defparameter *unexpected-passes* 0)
6
7 (defvar *use-html-output-p* t)
8 (defvar *timestamp* nil)
9
10 (defmacro test (condition)
11   `(progn
12      (cond
13        (,condition
14         (format t "Test `~S' passed~%" ',condition)
15         (incf *passed-tests*))
16        (t
17         (if *use-html-output-p*
18             (format t "<font color='red'>Test `~S' failed.</font>~%" ',condition)
19             (format t "Test `~S' failed.~%" ',condition))
20         (incf *failed-tests*)))
21      (incf *total-tests*)))
22
23 (defmacro expected-failure (condition)
24   `(progn
25      (cond
26        (,condition
27         (if *use-html-output-p*
28             (format t "<font color='orange'>Test `~S' passed unexpectedly!</font>~%" ',condition)
29             (format t "Test `~S' passed unexpectedly!~%" ',condition))
30         (incf *unexpected-passes*))
31        (t
32         (format t "Test `~S' failed expectedly.~%" ',condition)
33         (incf *expected-failures*)))
34      (incf *total-tests*)))
35
36 (defmacro test-equal (form value)
37   `(test (equal ,form, value)))
38
39
40 (format t "Running tests...~%~%")
41 (setq *timestamp* (get-internal-real-time))