1 |
;-*- Mode: Lisp -*- |
;-*- Mode: Lisp -*- |
2 |
;;;; Author: Paul Dietz |
;;;; Author: Paul Dietz |
3 |
;;;; Created: Sat May 24 21:31:55 2003 |
;;;; Created: Sat May 24 21:31:55 2003 |
4 |
;;;; Contains: Tests of DEFGENERIC with :method-combination |
;;;; Contains: Tests of DEFGENERIC with :method-combination + |
5 |
|
|
6 |
(in-package :cl-test) |
(in-package :cl-test) |
7 |
|
|
8 |
(declaim (special *x*)) |
(declaim (special *x*)) |
9 |
|
|
|
(defclass dgmc-class-01 () ()) |
|
|
(defclass dgmc-class-02 (dgmc-class-01) ()) |
|
|
(defclass dgmc-class-03 (dgmc-class-01) ()) |
|
|
(defclass dgmc-class-04 (dgmc-class-02 dgmc-class-03) ()) |
|
|
(defclass dgmc-class-05 (dgmc-class-04) ()) |
|
|
(defclass dgmc-class-06 (dgmc-class-04) ()) |
|
|
(defclass dgmc-class-07 (dgmc-class-05 dgmc-class-06) ()) |
|
|
|
|
10 |
(deftest defgeneric-method-combination.+.1 |
(deftest defgeneric-method-combination.+.1 |
11 |
(let ((*x* nil) |
(let ((*x* nil) |
12 |
(fn |
(fn |
13 |
(eval '(defgeneric dg-mc.fun.1 (x) |
(eval '(defgeneric dg-mc.fun.plus.1 (x) |
14 |
(:method-combination +) |
(:method-combination +) |
15 |
(:method + ((x integer)) (car (push 8 *x*))) |
(:method + ((x integer)) (car (push 8 *x*))) |
16 |
(:method + ((x rational)) (car (push 4 *x*))) |
(:method + ((x rational)) (car (push 4 *x*))) |
25 |
(deftest defgeneric-method-combination.+.2 |
(deftest defgeneric-method-combination.+.2 |
26 |
(let ((*x* nil) |
(let ((*x* nil) |
27 |
(fn |
(fn |
28 |
(eval '(defgeneric dg-mc.fun.2 (x) |
(eval '(defgeneric dg-mc.fun.plus.2 (x) |
29 |
(:method-combination + :most-specific-first) |
(:method-combination + :most-specific-first) |
30 |
(:method + ((x integer)) (car (push 8 *x*))) |
(:method + ((x integer)) (car (push 8 *x*))) |
31 |
(:method + ((x rational)) (car (push 4 *x*))) |
(:method + ((x rational)) (car (push 4 *x*))) |
40 |
(deftest defgeneric-method-combination.+.3 |
(deftest defgeneric-method-combination.+.3 |
41 |
(let ((*x* nil) |
(let ((*x* nil) |
42 |
(fn |
(fn |
43 |
(eval '(defgeneric dg-mc.fun.3 (x) |
(eval '(defgeneric dg-mc.fun.plus.3 (x) |
44 |
(:method-combination + :most-specific-last) |
(:method-combination + :most-specific-last) |
45 |
(:method + ((x integer)) (car (push 8 *x*))) |
(:method + ((x integer)) (car (push 8 *x*))) |
46 |
(:method + ((x rational)) (car (push 4 *x*))) |
(:method + ((x rational)) (car (push 4 *x*))) |
54 |
|
|
55 |
(deftest defgeneric-method-combination.+.4 |
(deftest defgeneric-method-combination.+.4 |
56 |
(let ((fn |
(let ((fn |
57 |
(eval '(defgeneric dg-mc.4 (x) |
(eval '(defgeneric dg-mc.plus.4 (x) |
58 |
(:method-combination +) |
(:method-combination +) |
59 |
(:method + ((x integer)) 1) |
(:method + ((x integer)) 1) |
60 |
(:method :around ((x rational)) 'foo) |
(:method :around ((x rational)) 'foo) |
71 |
|
|
72 |
(deftest defgeneric-method-combination.+.5 |
(deftest defgeneric-method-combination.+.5 |
73 |
(let ((fn |
(let ((fn |
74 |
(eval '(defgeneric dg-mc.5 (x) |
(eval '(defgeneric dg-mc.plus.5 (x) |
75 |
(:method-combination +) |
(:method-combination +) |
76 |
(:method + ((x integer)) 1) |
(:method + ((x integer)) 1) |
77 |
(:method :around ((x rational)) |
(:method :around ((x rational)) |
89 |
|
|
90 |
(deftest defgeneric-method-combination.+.6 |
(deftest defgeneric-method-combination.+.6 |
91 |
(let ((fn |
(let ((fn |
92 |
(eval '(defgeneric dg-mc.6 (x) |
(eval '(defgeneric dg-mc.plus.6 (x) |
93 |
(:method-combination +) |
(:method-combination +) |
94 |
(:method + ((x integer)) 1) |
(:method + ((x integer)) 1) |
95 |
(:method :around ((x rational)) |
(:method :around ((x rational)) |
110 |
|
|
111 |
(deftest defgeneric-method-combination.+.7 |
(deftest defgeneric-method-combination.+.7 |
112 |
(let ((fn |
(let ((fn |
113 |
(eval '(defgeneric dg-mc.7 (x) |
(eval '(defgeneric dg-mc.plus.7 (x) |
114 |
(:method-combination +) |
(:method-combination +) |
115 |
(:method + ((x dgmc-class-04)) 1) |
(:method + ((x dgmc-class-04)) 1) |
116 |
(:method + ((x dgmc-class-03)) 2) |
(:method + ((x dgmc-class-03)) 2) |
125 |
|
|
126 |
(deftest defgeneric-method-combination.+.8 |
(deftest defgeneric-method-combination.+.8 |
127 |
(let ((fn |
(let ((fn |
128 |
(eval '(defgeneric dg-mc.8 (x) |
(eval '(defgeneric dg-mc.plus.8 (x) |
129 |
(:method-combination +) |
(:method-combination +) |
130 |
(:method + ((x (eql 1000))) 1) |
(:method + ((x (eql 1000))) 1) |
131 |
(:method :around ((x symbol)) (values)) |
(:method :around ((x symbol)) (values)) |