1.0.23.58: bug 405 has been fixed a while now
[sbcl/tcr.git] / tests / mop-3.impure-cload.lisp
blobcb6f609903d55af3c71743e3bfba9fe710c92861
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 ;;; This file contains two tests for COMPUTE-APPLICABLE-METHODS on
15 ;;; subclasses of generic functions.
17 ;;; tests from Bruno Haible (sbcl-devel 2004-08-02)
19 (defpackage "MOP-3"
20 (:use "CL" "SB-MOP"))
22 (in-package "MOP-3")
24 (defclass msl-generic-function (standard-generic-function)
26 (:metaclass funcallable-standard-class))
28 (defun reverse-method-list (methods)
29 (let ((result '()))
30 (dolist (method methods)
31 (if (and (consp result)
32 (equal (method-qualifiers method)
33 (method-qualifiers (caar result))))
34 (push method (car result))
35 (push (list method) result)))
36 (reduce #'append result)))
38 (defmethod compute-applicable-methods ((gf msl-generic-function) arguments)
39 (reverse-method-list (call-next-method)))
40 (defmethod compute-applicable-methods-using-classes
41 ((gf msl-generic-function) classes)
42 (reverse-method-list (call-next-method)))
44 (defgeneric testgf07 (x)
45 (:generic-function-class msl-generic-function)
46 (:method ((x integer))
47 (cons 'integer (if (next-method-p) (call-next-method))))
48 (:method ((x real))
49 (cons 'real (if (next-method-p) (call-next-method))))
50 (:method ((x number))
51 (cons 'number (if (next-method-p) (call-next-method))))
52 (:method :around ((x integer))
53 (coerce (call-next-method) 'vector)))
55 (assert (equalp (list (testgf07 5.0) (testgf07 17))
56 '((number real) #(number real integer))))
58 (defclass nonumber-generic-function (standard-generic-function)
60 (:metaclass funcallable-standard-class))
62 (defun nonumber-method-list (methods)
63 (remove-if #'(lambda (method)
64 (member (find-class 'number)
65 (sb-pcl:method-specializers method)))
66 methods))
68 (defmethod compute-applicable-methods
69 ((gf nonumber-generic-function) arguments)
70 (nonumber-method-list (call-next-method)))
71 (defmethod compute-applicable-methods-using-classes
72 ((gf nonumber-generic-function) classes)
73 (nonumber-method-list (call-next-method)))
75 (defgeneric testgf08 (x)
76 (:generic-function-class nonumber-generic-function)
77 (:method ((x integer))
78 (cons 'integer (if (next-method-p) (call-next-method))))
79 (:method ((x real))
80 (cons 'real (if (next-method-p) (call-next-method))))
81 (:method ((x number))
82 (cons 'number (if (next-method-p) (call-next-method))))
83 (:method :around ((x integer))
84 (coerce (call-next-method) 'vector)))
86 (assert (equalp (list (testgf08 5.0) (testgf08 17))
87 '((real) #(integer real))))