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 ;;; this file contains tests of REINITIALIZE-INSTANCE on generic
18 (:use
"CL" "SB-MOP" "TEST-UTIL"))
22 (defclass my-generic-function
(standard-generic-function)
24 (:metaclass funcallable-standard-class
))
27 (:method-combination list
)
28 (:method list
((x float
)) (* x x
))
29 (:method list
((x integer
)) (1+ x
))
30 (:method list
((x number
)) (expt x
2))
31 (:generic-function-class my-generic-function
))
33 (assert (equal (foo 3) '(4 9)))
34 (defmethod compute-discriminating-function ((gf my-generic-function
))
35 (let ((orig (call-next-method)))
37 (let ((orig-result (apply orig args
)))
38 (cons gf
(reverse orig-result
))))))
39 (assert (equal (foo 3) '(4 9)))
40 (reinitialize-instance #'foo
)
41 (assert (equal (foo 3) (cons #'foo
'(9 4))))