X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests.lisp;h=65b4ae2021560e8162e53115e8f06b31344af2f3;hb=b80d28ea6387828e6a095ffa835b9b631c5749ea;hp=b230068c023f96093ab1aab012bbd0b0b6b1da81;hpb=ad091133b3c6e27c105f6631076cb408df386d42;p=jscl.git diff --git a/tests.lisp b/tests.lisp index b230068..65b4ae2 100644 --- a/tests.lisp +++ b/tests.lisp @@ -1,15 +1,45 @@ -(defvar *passed-tets* 0) -(defvar *failed-tets* 0) -(defvar *timestamp* (get-internal-real-time)) +(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-tets*)) - (t - (write-line ,(concat "Test `" (prin1-to-string condition) "' failed.")) - (incf *failed-tets*)))) + `(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 "") + +(setq *timestamp* (get-internal-real-time))