aboutsummaryrefslogtreecommitdiff
path: root/src/standard-hooks.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/standard-hooks.lisp')
-rw-r--r--src/standard-hooks.lisp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/standard-hooks.lisp b/src/standard-hooks.lisp
index 86725ca..0548865 100644
--- a/src/standard-hooks.lisp
+++ b/src/standard-hooks.lisp
@@ -2,6 +2,29 @@
(in-package :testiere)
+;;; COMMON FUNCTIONS
+
+(defun standard-extractor (orig-form)
+ "A somewhat naive default test form extractor. Returns two values,
+orig-form without test forms included, and a collection of test forms."
+ (loop
+ :for form :in orig-form
+ :when (and (listp form)
+ (eq :tests (first form)))
+ :append (cdr form) :into tests-forms
+ :else
+ :collect form :into defun-form
+ :finally (return (values defun-form tests-forms))))
+
+(defun standard-form-key (form)
+ "The first is a list (MACRO NAME) that uniquely identifies the form
+form which tests are being defined. NAME's package is the suite to
+which the tests of FORM will be be added.
+
+This form key function is sutable for Common Lisp definition macros."
+ (list (first form) (second form)))
+
+
;;; DEFSTRUCT
;; (defstruct moo
@@ -11,6 +34,7 @@
(register-hook
'cl:defstruct
+ #'standard-form-key
#'standard-extractor)
;;; DEFCLASS
@@ -30,6 +54,7 @@
(register-hook
'cl:defclass
#'standard-extractor
+ #'standard-form-key
#'defclass-restarts-expander)
;;; DEFMETHOD
@@ -40,7 +65,7 @@
;; (:tests ...)
;; (flah (moo-blah x) (barbar y)))
-(register-hook 'cl:defmethod #'standard-extractor)
+(register-hook 'cl:defmethod #'standard-extractor #'standard-form-key)
;;; DEFUN
@@ -57,7 +82,7 @@
()
(fmakunbound ',name)))))
-(register-hook 'cl:defun #'standard-extractor #'defun-restarts-expander)
+(register-hook 'cl:defun #'standard-extractor #'standard-form-key #'defun-restarts-expander)
;;; DEFTYPE
@@ -67,4 +92,4 @@
;; (:tests ...)
;; `(or number null))
-(register-hook 'cl:deftype #'standard-extractor)
+(register-hook 'cl:deftype #'standard-extractor #'standard-form-key)