Remove remnants of non-interleavable raw slot spport.
[sbcl.git] / tests / mop-23.impure.lisp
blob8080afe2b3467e77769a69a9a3b5bc2dfbd9c85c
1 ;;;; miscellaneous side-effectful tests of the MOP
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 ;;; Extending MAKE-METHOD-LAMBDA, and making sure that the resulting
15 ;;; method functions compile without warnings.
17 (defpackage "MOP-23"
18 (:use "CL" "SB-MOP"))
20 (in-package "MOP-23")
22 (defclass verbose-generic-function (standard-generic-function) ()
23 (:metaclass funcallable-standard-class))
24 (defmethod make-method-lambda
25 ((gf verbose-generic-function) method lambda env)
26 (multiple-value-bind (lambda initargs)
27 (call-next-method)
28 (values
29 `(lambda (args next-methods)
30 (format *trace-output* "Called a method!")
31 (,lambda args next-methods))
32 initargs)))
34 (defgeneric foo (x)
35 (:generic-function-class verbose-generic-function))
37 (handler-bind ((warning #'error))
38 (eval '(defmethod foo ((x integer)) (1+ x))))
40 (assert (string= (with-output-to-string (*trace-output*)
41 (assert (= (foo 3) 4)))
42 "Called a method!"))
44 (defclass super () ((a :initarg :a)))
45 (defclass sub (super) (b))
47 (handler-bind ((warning #'error))
48 (eval '(defmethod foo ((x sub)) (slot-boundp x 'b)))
49 (eval '(defmethod foo :around ((x super))
50 (list (slot-value x 'a) (call-next-method)))))
52 (assert (string= (with-output-to-string (*trace-output*)
53 (assert (equal (foo (make-instance 'sub :a 4))
54 '(4 nil))))
55 "Called a method!Called a method!"))
57 (defclass super ()
58 ((b :initform 3)
59 (a :initarg :a)))
61 (assert (string= (with-output-to-string (*trace-output*)
62 (assert (equal (foo (make-instance 'sub :a 5))
63 '(5 t))))
64 "Called a method!Called a method!"))