From d22db16f1791e4af8bcb143ce9d230950904d85d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Thu, 29 Aug 2013 15:09:07 +0200 Subject: [PATCH] Execute tests asynchronously to let the browser to render --- src/print.lisp | 2 +- tests.lisp | 56 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/print.lisp b/src/print.lisp index 146c173..0f61573 100644 --- a/src/print.lisp +++ b/src/print.lisp @@ -211,7 +211,7 @@ ;; the symbol with the optional package or uninterned mark. (progn (cond - ((null package) (write-char #\#)) + ((null package) (write-char #\# stream)) ((eq package (find-package "KEYWORD"))) (t (write-char (escape-token (package-name package)) stream))) (write-char #\: stream) diff --git a/tests.lisp b/tests.lisp index 594c7cc..c0760b9 100644 --- a/tests.lisp +++ b/tests.lisp @@ -7,31 +7,43 @@ (defvar *use-html-output-p* t) (defvar *timestamp* nil) +(defun test-fn (condition form) + (cond + (condition + (format t "Test `~S' passed~%" form) + (incf *passed-tests*)) + (t + (if *use-html-output-p* + (format t "Test `~S' failed.~%" form) + (format t "Test `~S' failed.~%" form)) + (incf *failed-tests*))) + (incf *total-tests*)) + +(defun expected-failure-fn (condition form) + (cond + (condition + (if *use-html-output-p* + (format t "Test `~S' passed unexpectedly!~%" form) + (format t "Test `~S' passed unexpectedly!~%" form)) + (incf *unexpected-passes*)) + (t + (format t "Test `~S' failed expectedly.~%" form) + (incf *expected-failures*))) + (incf *total-tests*)) + + +#+jscl +(defmacro test (condition) + `(funcall (oget *root* "setTimeout") + (lambda () + (test-fn ,condition ',condition)) + 0)) +#-jscl (defmacro test (condition) - `(progn - (cond - (,condition - (format t "Test `~S' passed~%" ',condition) - (incf *passed-tests*)) - (t - (if *use-html-output-p* - (format t "Test `~S' failed.~%" ',condition) - (format t "Test `~S' failed.~%" ',condition)) - (incf *failed-tests*))) - (incf *total-tests*))) + `(test-fn ,condition ',condition)) (defmacro expected-failure (condition) - `(progn - (cond - (,condition - (if *use-html-output-p* - (format t "Test `~S' passed unexpectedly!~%" ',condition) - (format t "Test `~S' passed unexpectedly!~%" ',condition)) - (incf *unexpected-passes*)) - (t - (format t "Test `~S' failed expectedly.~%" ',condition) - (incf *expected-failures*))) - (incf *total-tests*))) + `(expected-failure-fn ,condition ',condition)) (defmacro test-equal (form value) `(test (equal ,form, value))) -- 1.7.10.4