1.0.19.30: muffle code deletion note from destructuring-bind
[sbcl/eslaughter.git] / tests / clos.pure.lisp
blobae8b524a625b73914e1f6ebf87078927e8165e5a
1 ;;;; CLOS tests with no side effects
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.
14 (cl:in-package :cl-user)
16 ;;; not really a test for observable behaviour, but: make sure that
17 ;;; all generic functions on startup have lambda lists known to the
18 ;;; system, because some functionality (e.g. &key argument checking)
19 ;;; depends on it. The basic functionality is tested elsewhere, but
20 ;;; this is to investigate the internals for possible inconsistency.
21 (assert (null
22 (let (collect)
23 (sb-pcl::map-all-generic-functions
24 (lambda (gf)
25 (let ((arg-info (sb-pcl::gf-arg-info gf)))
26 (when (eq (sb-pcl::arg-info-lambda-list arg-info)
27 :no-lambda-list)
28 (push gf collect)))))
29 (print (nreverse collect)))))
31 ;;; Regressing test for invalid slot specification error printing
32 (multiple-value-bind (value err)
33 (ignore-errors (macroexpand '(defclass foo () (frob (frob bar)))))
34 (declare (ignore value))
35 (assert (typep err 'simple-condition))
36 (multiple-value-bind (value format-err)
37 (ignore-errors (apply #'format nil
38 (simple-condition-format-control err)
39 (simple-condition-format-arguments err)))
40 (declare (ignore value))
41 (assert (not format-err))))
43 ;;; another not (user-)observable behaviour: make sure that
44 ;;; sb-pcl::map-all-classes calls its function on each class once and
45 ;;; exactly once.
46 (let (result)
47 (sb-pcl::map-all-classes (lambda (c) (push c result)))
48 (assert (equal result (remove-duplicates result))))
50 ;;; this one's user-observable
51 (assert (typep #'(setf class-name) 'generic-function))
53 ;;; CLHS 1.4.4.5. We could test for this by defining methods
54 ;;; (i.e. portably) but it's much easier using the MOP and
55 ;;; MAP-ALL-CLASSES.
56 (flet ((standardized-class-p (c)
57 (eq (class-name c) (find-symbol (symbol-name (class-name c)) "CL"))))
58 (let (result)
59 (sb-pcl::map-all-classes
60 (lambda (c) (when (standardized-class-p c)
61 (let* ((cpl (sb-mop:class-precedence-list c))
62 (std (position (find-class 'standard-object) cpl))
63 (str (position (find-class 'structure-object) cpl))
64 (last (position-if
65 #'standardized-class-p (butlast cpl)
66 :from-end t)))
67 (when (and std str)
68 (push `(:and ,c) result))
69 (when (and str (< str last))
70 (push `(:str ,c) result))
71 (when (and std (< std last))
72 (push `(:std ,c) result))))))
73 (assert (null result))))
75 ;; No compiler-notes for non-constant slot-names in default policy.
76 (handler-case
77 (compile nil '(lambda (x y z)
78 (setf (slot-value x z)
79 (slot-value y z))))
80 (sb-ext:compiler-note (e)
81 (error e)))