Colorize test output
[jscl.git] / tests.lisp
1 (defvar *total-tests* 0)
2 (defvar *passed-tests* 0)
3 (defvar *failed-tests* 0)
4
5 (defvar *expected-failures* 0)
6 (defvar *unexpected-passes* 0)
7
8 (defvar *timestamp* nil)
9
10 (defmacro test (condition)
11   `(progn
12      (cond
13        (,condition
14         (write-line ,(concat "Test `" (prin1-to-string condition) "' passed"))
15         (incf *passed-tests*))
16        (t
17         (write-line ,(concat "<font color=red>Test `"
18                              (prin1-to-string condition) 
19                              "' failed.</font>"))
20         (incf *failed-tests*)))
21      (incf *total-tests*)))
22
23 (defmacro expected-failure (condition)
24   `(progn
25      (cond
26        (,condition
27         (write-line ,(concat "<font color=orange>Test `"
28                              (prin1-to-string condition)
29                              "' passed unexpectedly!</font>"))
30         (incf *unexpected-passes*))
31        (t
32         (write-line ,(concat "Test `" (prin1-to-string condition) "' failed expectedly."))
33         (incf *expected-failures*)))
34      (incf *total-tests*)))
35
36 (write-line "Running tests...")
37 (write-line "")
38
39 (setq *timestamp* (get-internal-real-time))