From a9088fe72b0a995fa8fafd419f664ce7b0a4c07e Mon Sep 17 00:00:00 2001 From: "Thomas M. Hermann" Date: Tue, 29 Jan 2013 07:13:43 -0600 Subject: [PATCH] Guard against multiple evaluations of a unit test name. --- lisp-unit.lisp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lisp-unit.lisp b/lisp-unit.lisp index d440f53..282b978 100644 --- a/lisp-unit.lisp +++ b/lisp-unit.lisp @@ -188,18 +188,20 @@ assertion.") (defmacro define-test (name &body body) "Store the test in the test database." - (multiple-value-bind (doc tag code) (parse-body body) - `(let ((doc (or ,doc (string ',name)))) - (setf - ;; Unit test - (gethash ',name (package-table *package* t)) - (make-instance 'unit-test :doc doc :code ',code)) - ;; Tags - (loop for tag in ',tag do - (pushnew - ',name (gethash tag (package-tags *package* t)))) - ;; Return the name of the test - ',name))) + (let ((qname (gensym "NAME-"))) + (multiple-value-bind (doc tag code) (parse-body body) + `(let* ((,qname ',name) + (doc (or ,doc (string ,qname)))) + (setf + ;; Unit test + (gethash ,qname (package-table *package* t)) + (make-instance 'unit-test :doc doc :code ',code)) + ;; Tags + (loop for tag in ',tag do + (pushnew + ,qname (gethash tag (package-tags *package* t)))) + ;; Return the name of the test + ,qname)))) ;;; Manage tests -- 2.11.4.GIT