;; Function To Be Tested: documentation ;; ;; Source: Guy L Steele's CLTL ;; Section: 25.2 Miscellaneous Features (Documentation) ;; Page: 440 ;; ;; Created By: John Park ;; ;; Creation Date: Sep 18, 1986 ;; ;; Last Update: ;; ;; Filed As: {ERIS}CML>TEST>25-2-documentation.test ;; ;; ;; Syntax: (documentation symbol doc-type) ;; ;; Function Description: This function returns the documentation string of type ;; doc-type for the symbol, or nil if none exists. Some kinds of documentation ;; are provided automatically by certain Common Lisp constructs if the user ;; writes an optional documentation string within them: ;; ;; ;; Argument(s): symbol: symbol ;; doc-type: symbol ;; Variable (defvar, defparameter, and defconstant) ;; Function (defun and defmacro) ;; Structure (defstruct) ;; Type (deftype) ;; Setf (defsetf) ;; ;; Returns: string of type doc-type for the symbol or nil ;; ;; Constraints/limitations: (do-test-group (documentation-test-setup :before (progn (defun discriminant (a b c) (declare (number a b c)) "computes the discriminant for a quadratic equation" (- (* b b) (* 4 a c))) (defvar *visible-windows* 1 "number of visible windows") (defsetf accessfn updatefn "expands into a call on updatefn") (defsetf foo (x) (y) "Doc for FOO's SETF" nil) (define-setf-method baz (x) "Doc for BAZ's SETF" (values 1 2 3 4 5)) (deftype square-matrix (&optional type size) "square-matrix includes all square two-dimensional arrays" `(array ,type (,size ,size))) (defmacro arithmetic-if (test neg-form zero-form pos-form) "if analogous to the FORTRAN arithmetic IF" (let ((var (gensym))) `(let ((,var ,test)) (cond ((< ,var 0) ,neg-form) ((= ,var 0) ,zero-form) (t ,pos-form))))) (defstruct line "line has points x and y" x y))) (do-test "documentation-test" (and (string-equal (documentation 'discriminant 'function) "computes the discriminant for a quadratic equation") (string-equal (documentation '*visible-windows* 'variable) "number of visible windows") (string-equal (documentation 'line 'structure) "line has points x and y") (string-equal (documentation 'square-matrix 'type) "square-matrix includes all square two-dimensional arrays") (string-equal (documentation 'arithmetic-if 'function) "if analogous to the FORTRAN arithmetic IF") (string-equal (documentation 'accessfn 'setf) "expands into a call on updatefn") (string-equal (documentation 'foo 'setf) "Doc for FOO's SETF") (string-equal (documentation 'baz 'setf) "Doc for BAZ's SETF") ))) STOP