1 ;;;; miscellaneous non-side-effectful tests of the MOP
3 ;;;; This software is part of the SBCL system. See the README file for
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
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 ;;;; Note that the MOP is not in an entirely supported state.
15 ;;;; However, this seems a good a way as any of ensuring that we have
18 (assert (subtypep 'sb-mop
:funcallable-standard-object
'standard-object
))
20 (assert (find (find-class 'sb-mop
:funcallable-standard-object
)
21 (sb-mop:class-direct-subclasses
(find-class 'standard-object
))))
23 (assert (find (find-class 'standard-object
)
24 (sb-mop:class-direct-superclasses
25 (find-class 'sb-mop
:funcallable-standard-object
))))
27 (dolist (name '(sb-mop:generic-function
28 sb-mop
:method sb-mop
:method-combination
29 sb-mop
:slot-definition sb-mop
:specializer
))
30 (assert (find (find-class 'sb-mop
:metaobject
)
31 (sb-mop:class-direct-superclasses
(find-class name
))))
32 (assert (subtypep name
'sb-mop
:metaobject
)))
34 ;;; No portable class Cp may inherit, by virtue of being a direct or
35 ;;; indirect subclass of a specified class, any slot for which the
36 ;;; name is a symbol accessible in the common-lisp-user package or
37 ;;; exported by any package defined in the ANSI Common Lisp standard.
38 (let ((specified-class-names
39 '(sb-mop:built-in-class
41 sb-mop
:direct-slot-definition
42 sb-mop
:effective-slot-definition
43 sb-mop
:eql-specializer
44 sb-mop
:forward-referenced-class
45 sb-mop
:funcallable-standard-class
46 sb-mop
:funcallable-standard-object
47 sb-mop
:generic-function
50 sb-mop
:method-combination
51 sb-mop
:slot-definition
53 sb-mop
:standard-accessor-method
55 sb-mop
:standard-direct-slot-definition
56 sb-mop
:standard-effective-slot-definition
57 sb-mop
:standard-generic-function
58 sb-mop
:standard-method
59 sb-mop
:standard-object
60 sb-mop
:standard-reader-method
61 sb-mop
:standard-slot-definition
62 sb-mop
:standard-writer-method
)))
63 (labels ((slot-name-ok (name)
64 (dolist (package (mapcar #'find-package
65 '("CL" "CL-USER" "KEYWORD" "SB-MOP"))
67 (when (multiple-value-bind (symbol status
)
68 (find-symbol (symbol-name name
) package
)
70 (or (eq package
(find-package "CL-USER"))
71 (eq status
:external
))))
73 (test-class-slots (class)
74 (loop for slot in
(sb-mop:class-slots class
)
75 for slot-name
= (sb-mop:slot-definition-name slot
)
76 unless
(slot-name-ok slot-name
)
77 collect
(cons class slot-name
))))
78 (loop for class-name in specified-class-names
79 for class
= (find-class class-name
)
80 for results
= (test-class-slots class
)
81 when results do
(cerror "continue" "~A" results
))))