X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Ftest.lisp;h=616b77eb1197a03d7882eb76d8681527a923ec07;hb=0cb2d1a0abb76375e059d5029083ffc34b325b6b;hp=e046859f304c05782da044ad3518fc048971ef95;hpb=1b24abf09e9fbb2a23c25a9583e5547514482f1b;p=fiveam.git diff --git a/src/test.lisp b/src/test.lisp index e046859..616b77e 100644 --- a/src/test.lisp +++ b/src/test.lisp @@ -1,6 +1,6 @@ -;; -*- lisp -*- +;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- -(in-package :it.bese.FiveAM) +(in-package :it.bese.fiveam) ;;;; * Tests @@ -11,11 +11,20 @@ ;;;; collection of checks which can be run and a test suite is a named ;;;; collection of tests and test suites. -(deflookup-table test - :at-redefinition nil - :documentation "Lookup table mapping test (and test suite) +(defvar *test* + (make-hash-table :test 'eql) + "Lookup table mapping test (and test suite) names to objects.") +(defun get-test (key &optional default) + (gethash key *test* default)) + +(defun (setf get-test) (value key) + (setf (gethash key *test*) value)) + +(defun rem-test (key) + (remhash key *test*)) + (defun test-names () (loop for test being the hash-keys of *test* collect test)) @@ -45,7 +54,7 @@ If DEPENDS-ON is a symbol it is interpreted as `(AND ,depends-on), this is accomadate the common case of one test depending on another. -FIXTURE specifies a fixtrue to wrap the body in. +FIXTURE specifies a fixture to wrap the body in. If PROFILE is T profiling information will be collected as well." (let* ((tmp (gensym)) @@ -65,19 +74,23 @@ If PROFILE is T profiling information will be collected as well." (destructuring-bind (name &rest args) (ensure-list fixture) `((with-fixture ,name ,args ,@body))) - body))) + body)) + (lambda-name + (format-symbol t "%~A-~A" '#:test name)) + (inner-lambda-name + (format-symbol t "%~A-~A" '#:inner-test name))) `(progn (setf (get-test ',name) (make-instance 'test-case :name ',name :runtime-package (find-package ,(package-name *package*)) :test-lambda - (lambda () + (named-lambda ,lambda-name () ,@ (ecase compile-at (:run-time `((funcall (let ((*package* (find-package ',(package-name *package*)))) - (compile nil '(lambda () - ,@effective-body)))))) + (compile ',inner-lambda-name + '(lambda () ,@effective-body)))))) (:definition-time effective-body))) :description ,description :depends-on ',depends-on