X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fclos.pure.lisp;h=803b48a674768239a97336d5e7145436aa6aacc1;hb=0e03a9ac950b78d776c4869c809e202d9e929f39;hp=377c7e887fcc2e1e909223df06d7f31722195a18;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/tests/clos.pure.lisp b/tests/clos.pure.lisp index 377c7e8..803b48a 100644 --- a/tests/clos.pure.lisp +++ b/tests/clos.pure.lisp @@ -39,3 +39,35 @@ (simple-condition-format-arguments err))) (declare (ignore value)) (assert (not format-err)))) + +;;; another not (user-)observable behaviour: make sure that +;;; sb-pcl::map-all-classes calls its function on each class once and +;;; exactly once. +(let (result) + (sb-pcl::map-all-classes (lambda (c) (push c result))) + (assert (equal result (remove-duplicates result)))) + +;;; this one's user-observable +(assert (typep #'(setf class-name) 'generic-function)) + +;;; CLHS 1.4.4.5. We could test for this by defining methods +;;; (i.e. portably) but it's much easier using the MOP and +;;; MAP-ALL-CLASSES. +(flet ((standardized-class-p (c) + (find-symbol (symbol-name (class-name c)) "CL"))) + (let (result) + (sb-pcl::map-all-classes + (lambda (c) (when (standardized-class-p c) + (let* ((cpl (sb-mop:class-precedence-list c)) + (std (position (find-class 'standard-object) cpl)) + (str (position (find-class 'structure-object) cpl)) + (last (position-if + #'standardized-class-p (butlast cpl) + :from-end t))) + (when (and std str) + (push `(:and ,c) result)) + (when (and str (< str last)) + (push `(:str ,c) result)) + (when (and std (< std last)) + (push `(:std ,c) result)))))) + (assert (null result))))