X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=symbols.lisp;h=f4e3b6dda0d35612da9659696eba8942cf2c0ab0;hp=5a8a3485cfb9f6582301bf44bd286a2fe03bf481;hb=7367c68a5daa2ef45c7adf1f4097596f84f5e4dd;hpb=79ce9975800c5c9e968c5db342add2d01a5cd83b diff --git a/symbols.lisp b/symbols.lisp index 5a8a348..f4e3b6d 100644 --- a/symbols.lisp +++ b/symbols.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: symbols.lisp,v 1.3 2003/07/16 16:01:37 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -46,7 +46,7 @@ ;;; Symbol functions (eval-when (:compile-toplevel :load-toplevel :execute) - (when (char= #\a (symbol-name '#:a)) + (when (char= #\a (schar (symbol-name '#:a) 0)) (pushnew :lowercase-reader *features*))) (defun string-default-case (str) @@ -106,3 +106,31 @@ (format t "~&Function ~S~T -> ~S~%" sym (symbol-function sym)))))) + +(defun find-test-generic-functions (instance) + "Return a list of symbols for generic functions specialized on the +class of an instance and whose name begins with the string 'test-'" + (let ((res) + (package (symbol-package (class-name (class-of instance))))) + (do-symbols (s package) + (multiple-value-bind (sym status) + (find-symbol (symbol-name s) package) + (when (and (or (eq status :external) + (eq status :internal)) + (fboundp sym) + (eq (symbol-package sym) package) + (> (length (symbol-name sym)) 5) + (string-equal "test-" (subseq (symbol-name sym) 0 5)) + (typep (symbol-function sym) 'generic-function) + (plusp + (length + (compute-applicable-methods + (ensure-generic-function sym) + (list instance))))) + (push sym res)))) + (nreverse res))) + +(defun run-tests-for-instance (instance) + (dolist (gf-name(find-test-generic-functions instance)) + (funcall gf-name instance)) + (values))