0.pre7.74:
[sbcl.git] / tests / interface.pure.lisp
1 ;;;; tests for problems in the interface presented to the user/programmer
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; from CMU CL.
9 ;;;; 
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
13
14 (in-package :cl-user)
15 \f
16 ;;;; properties of symbols, e.g. presence of doc strings for public symbols
17
18 ;;; Check for fbound external symbols in public packages that have no
19 ;;; argument list information. (This used to be possible when we got
20 ;;; carried away with byte compilation, since the byte compiler can't
21 ;;; record argument list information. Now that there's no byte
22 ;;; compiler, that can't happen, but it still shouldn't hurt to check
23 ;;; in case the argument information goes astray some other way.)
24 (defvar *public-package-names*
25   '("SB-ALIEN" "SB-C-CALL" "SB-DEBUG" "SB-EXT" "SB-GRAY" "SB-MP"
26     "SB-PROFILE" "SB-PCL" "COMMON-LISP"))
27 (defun has-arglist-info-p (fun)
28   (declare (type function fun))
29   ;; The Lisp-level type FUNCTION can conceal a multitude of sins..
30   (case (sb-kernel:widetag-of fun)
31     ((#.sb-vm:simple-fun-header-widetag #.sb-vm:closure-fun-header-widetag)
32       (sb-kernel:%simple-fun-arglist fun))
33     (#.sb-vm:closure-header-widetag (has-arglist-info-p
34                                      (sb-kernel:%closure-fun fun)))
35     ;; In code/describe.lisp, ll. 227 (%describe-function), we use a scheme
36     ;; like above, and it seems to work. -- MNA 2001-06-12
37     ;;
38     ;; (There might be other cases with arglist info also.
39     ;; SIMPLE-FUN-HEADER-WIDETAG and CLOSURE-HEADER-WIDETAG just
40     ;; happen to be the two case that I had my nose rubbed in when
41     ;; debugging a GC problem caused by applying %SIMPLE-FUN-ARGLIST to
42     ;; a closure. -- WHN 2001-06-05)
43     (t nil)))
44 (defun check-ext-symbols-arglist (package)
45   (format t "~% looking at package: ~A" package)
46   (do-external-symbols (ext-sym package)
47     (when (fboundp ext-sym)
48       (let ((fun (symbol-function ext-sym)))
49         (cond ((macro-function ext-sym)
50                ;; FIXME: Macro functions should have their argument list
51                ;; information checked separately. Just feeding them into
52                ;; the ordinary-function logic below doesn't work right,
53                ;; though, and I haven't figured out what does work
54                ;; right. For now we just punt.
55                (values))
56               ((typep fun 'generic-function)
57                 (sb-pcl::generic-function-pretty-arglist fun))
58               (t
59                (let ((fun (symbol-function ext-sym)))
60                  (unless (has-arglist-info-p fun)
61                    (error "Function ~A has no arg-list information available."
62                           ext-sym)))))))))
63 (dolist (public-package *public-package-names*)
64   (when (find-package public-package)
65     (check-ext-symbols-arglist public-package)))
66 (terpri)
67
68 ;;; FIXME: It would probably be good to require here that every
69 ;;; external symbol either has a doc string or has some good excuse
70 ;;; (like being an accessor for a structure which has a doc string).
71 \f
72 ;;;; tests of interface machinery
73
74 ;;; APROPOS should accept a package designator, not just a package, and
75 ;;; furthermore do the right thing when it gets a package designator.
76 ;;; (bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-17)
77 (assert (< 0
78            (length (apropos-list "PRINT" :cl))
79            (length (apropos-list "PRINT"))))