1 ;;;; CHANGE-CLASS, obsolete instances, and methods on SLOT-VALUE-USING-CLASS
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 (defclass metaclass
(sb-mop:standard-class
) ())
16 (defmethod sb-mop:validate-superclass
((class metaclass
) (superclass t
))
19 (defmethod sb-mop:validate-superclass
((class standard-class
) (superclass metaclass
))
22 (defmethod sb-mop:validate-superclass
((class metaclass
) (superclass standard-class
))
25 (defmethod sb-mop:validate-superclass
((class metaclass
) (superclass metaclass
))
28 (defmethod sb-mop:direct-slot-definition-class
((class metaclass
) &rest initargs
)
29 (declare (ignore initargs
))
30 (find-class 'sb-mop
:standard-direct-slot-definition
))
32 (defmethod sb-mop:effective-slot-definition-class
((class metaclass
) &rest initargs
)
33 (declare (ignore initargs
))
34 (find-class 'sb-mop
:standard-effective-slot-definition
))
36 (defmethod sb-mop:slot-value-using-class
((class metaclass
) object slot
)
37 (if (eq 'test
(sb-mop:slot-definition-name slot
))
38 (* 2 (call-next-method))
41 (defmethod (setf sb-mop
:slot-value-using-class
) (value (class metaclass
) object slot
)
42 (if (eq 'test
(sb-mop:slot-definition-name slot
))
43 (call-next-method (/ value
2) class object slot
)
48 (:metaclass metaclass
))
50 (let ((a (make-instance 'stdclass
)))
51 (assert (= 2 (slot-value a
'test
)))
52 (change-class a
'stdclass
)
53 (assert (= 2 (slot-value a
'test
))))
55 ;;; check obsolete instance handling
56 (defvar *a
* (make-instance 'stdclass
))
60 (newtest :initform
4))
61 (:metaclass metaclass
))
63 (assert (= 2 (slot-value *a
* 'test
)))
64 (assert (= 4 (slot-value *a
* 'newtest
)))