X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests.lisp;h=65b4ae2021560e8162e53115e8f06b31344af2f3;hb=b80d28ea6387828e6a095ffa835b9b631c5749ea;hp=d383dc08e15b68afcae02caba960333eefbc7f98;hpb=14c6c745a82935545327e1406e24ece6cccbaf98;p=jscl.git diff --git a/tests.lisp b/tests.lisp index d383dc0..65b4ae2 100644 --- a/tests.lisp +++ b/tests.lisp @@ -1,15 +1,43 @@ -(defvar *passed-tests* 0) -(defvar *failed-tests* 0) +(defparameter *total-tests* 0) +(defparameter *passed-tests* 0) +(defparameter *failed-tests* 0) +(defparameter *expected-failures* 0) +(defparameter *unexpected-passes* 0) + +(defvar *use-html-output-p* t) +(defun if-html (string) (if *use-html-output-p* string "")) + (defvar *timestamp* nil) (defmacro test (condition) - `(cond - (,condition - (write-line ,(concat "Test `" (prin1-to-string condition) "' passed")) - (incf *passed-tests*)) - (t - (write-line ,(concat "Test `" (prin1-to-string condition) "' failed.")) - (incf *failed-tests*)))) + `(progn + (cond + (,condition + (write-line ,(concat "Test `" (prin1-to-string condition) "' passed")) + (incf *passed-tests*)) + (t + (write-line (concat (if-html "") + "Test `" + ,(prin1-to-string condition) + "' failed." + (if-html ""))) + (incf *failed-tests*))) + (incf *total-tests*))) + +(defmacro expected-failure (condition) + `(progn + (cond + (,condition + (write-line (concat (if-html "") + "Test `" + ,(prin1-to-string condition) + "' passed unexpectedly!" + (if-html ""))) + (incf *unexpected-passes*)) + (t + (write-line ,(concat "Test `" (prin1-to-string condition) "' failed expectedly.")) + (incf *expected-failures*))) + (incf *total-tests*))) (write-line "Running tests...") (write-line "")