1 ;;;; miscellaneous 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 ;;; a test that metaclasses can be instantiated even if there are
15 ;;; applicable methods for SLOT-VALUE-USING-CLASS with specialized
16 ;;; arguments that invoke slot readers. (Previously the PV
17 ;;; optimization for slot readers caused the new class's wrapper and
18 ;;; effective slot definitions to be available during class
21 (load "assertoid.lisp")
28 (defclass my-class
(standard-class)
30 (defmethod validate-superclass ((class my-class
) (super-class standard-class
))
33 ;;; the specialization of OBJECT here triggers the PV optimization;
34 ;;; with an unspecialized argument, the SLOT-VALUE is not optimized.
35 (defmethod slot-value-using-class
36 ((class my-class
) (object standard-object
) eslotd
)
38 (setf (slot-value object
'id
) 42)
40 (defclass my-object
()
41 ((id :type integer
:reader id-of
))
42 (:metaclass my-class
))
44 ;;; the first patch failed on code like this, because the STD-P field
45 ;;; of the accessor information was also computed lazily, but it is
46 ;;; needed in order to real with accessor cache misses.
47 (defun test-global-accessors ()
48 (let ((object (make-instance 'my-object
)))
49 (setf (slot-value object
'id
) 13)
51 (assert (= (id-of object
) 13))
52 (assert (= (slot-value object
'id
) 13)))
54 (assert (= (id-of object
) 42))
55 (assert (= (slot-value object
'id
) 42)))
57 (assert (= (id-of object
) 42))
58 (assert (= (slot-value object
'id
) 42)))))
59 (compile 'test-global-accessors
)
60 (test-global-accessors)