source: trunk/abcl/test/lisp/abcl/mop-tests-setup.lisp

Last change on this file was 15002, checked in by Mark Evenson, 7 years ago

Fix problems with SHARED-INITIALIZE

(Olof-Joachim Frahm)

Merges <https://github.com/armedbear/abcl/pull/42>.

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1;;; mop-tests-setup.lisp
2;;;
3;;; Copyright (C) 2010 Matthias Hölzl
4;;;
5;;; This program is free software; you can redistribute it and/or
6;;; modify it under the terms of the GNU General Public License
7;;; as published by the Free Software Foundation; either version 2
8;;; of the License, or (at your option) any later version.
9;;;
10;;; This program is distributed in the hope that it will be useful,
11;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13;;; GNU General Public License for more details.
14;;;
15;;; You should have received a copy of the GNU General Public License
16;;; along with this program; if not, write to the Free Software
17;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19;;; Definitions used by mop-tests.lisp.  Split into a separate file to
20;;; avoid problems with the functions not being available during test
21;;; runs.
22
23(in-package #:abcl.test.lisp)
24
25(defun find-classes (&rest args)
26  (mapcar #'find-class args))
27
28(defgeneric mop-test.foo (x y)
29  (:method (x y)
30    (list :object x :object y))
31  (:method ((x fixnum) y)
32    (list :fixnum x :object y))
33  (:method ((x fixnum) (y fixnum))
34    (list :fixnum x :fixnum y)))
35
36(defun find-foo (&rest specializers)
37  (find-method #'mop-test.foo nil
38         (mapcar #'find-class specializers)))
39
40(defgeneric mop-test.bar (x y)
41  (:method (x y)
42    (list :object x :object y))
43  (:method ((x fixnum) y)
44    (list :fixnum x :object y))
45  (:method ((x fixnum) (y fixnum))
46    (list :fixnum x :fixnum y))
47  (:method ((x fixnum) (y string))
48    (list :fixnum x :fixnum y))
49  (:method ((x fixnum) (y (eql 123)))
50    (list :fixnum x :123 y)))
51
52(defun find-bar (&rest specializers)
53  (find-method #'mop-test.bar nil
54   (mapcar #'find-class specializers)))
55
56(defgeneric mop-test.baz (x y)
57  (:method (x y)
58    (list :object x :object y))
59  (:method ((x fixnum) y)
60    (list :fixnum x :object y))
61  (:method ((x fixnum) (y fixnum))
62    (list :fixnum x :fixnum y))
63  (:method ((x (eql 234)) (y fixnum))
64    (list :234 x :fixnum y)))
65
66(defun find-baz (&rest specializers)
67  (find-method #'mop-test.baz nil
68         (mapcar #'find-class specializers)))
69
70(defgeneric mop-test.quux (x y)
71  (:method (x y)
72    (list :object x :object y))
73  (:method ((x fixnum) y)
74    (list :fixnum x :object y))
75  (:method ((x fixnum) (y fixnum))
76    (list :fixnum x :fixnum y))
77  (:method ((x (eql :foo)) (y fixnum))
78    (list :foo x :fixnum y)))
79
80(defun find-quux (&rest specializers)
81  (find-method #'mop-test.quux nil
82         (mapcar #'find-class specializers)))
83
84(defclass foo-meta-class (standard-class)
85  ())
86
87(defclass foo-direct-slot-definition (mop:standard-direct-slot-definition)
88  ())
89
90(defclass foo-effective-slot-definition (mop:standard-effective-slot-definition)
91  ())
92
93(defmethod mop:direct-slot-definition-class ((class foo-meta-class) &rest initargs)
94  (find-class 'foo-direct-slot-definition))
95
96(defmethod mop:effective-slot-definition ((class foo-meta-class) &rest initargs)
97  (find-class 'foo-effective-slot-definition))
98
99(defmethod mop:compute-effective-slot-definition ((class foo-meta-class) name direct-slots)
100  (car direct-slots))
101
102(defclass bar-class ()
103  ((x :initform T))
104  (:metaclass foo-meta-class))
105
106(defmethod mop:slot-boundp-using-class ((class foo-meta-class) object slot)
107  (error "foo"))
Note: See TracBrowser for help on using the repository browser.