From 00c8da1c2d42e9299ca734164a15012bd794fdf9 Mon Sep 17 00:00:00 2001 From: pfdietz <pfdietz@localhost> Date: Tue, 17 Jun 2003 12:40:49 +0000 Subject: [PATCH] Fixed up some error tests by removing bogus methods. This enables the defgeneric for dmc-gf-03 to be reevaluated without error. Added some tests of identity on one argument. --- ansi-tests/define-method-combination.lsp | 57 +++++++++++++++++++----- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/ansi-tests/define-method-combination.lsp b/ansi-tests/define-method-combination.lsp index 514faff8..102e086a 100644 --- a/ansi-tests/define-method-combination.lsp +++ b/ansi-tests/define-method-combination.lsp @@ -5,9 +5,19 @@ (in-package :cl-test) -(define-method-combination times - :documentation "Multiplicative method combination, version 1" - :operator *) +(defclass dmc-class-01a () ()) +(defclass dmc-class-01b (dmc-class-01a) ()) +(defclass dmc-class-01c (dmc-class-01a) ()) +(defclass dmc-class-01d (dmc-class-01b dmc-class-01c) ()) +(defclass dmc-class-01e (dmc-class-01c dmc-class-01b) ()) +(defclass dmc-class-01f (dmc-class-01d) ()) +(defclass dmc-class-01g (dmc-class-01a) ()) +(defclass dmc-class-01h (dmc-class-01f dmc-class-01g) ()) + +(defvar *dmc-times* + (define-method-combination times + :documentation "Multiplicative method combination, version 1" + :operator *)) (defgeneric dmc-gf-01 (x) (:method-combination times)) @@ -32,6 +42,10 @@ (error () :good)) :good) +(deftest define-method-combination-01.3 + *dmc-times* + times) + (defgeneric dmc-gf-02 (x) (:method-combination times)) (defmethod dmc-gf-02 times ((x integer)) 2) @@ -56,7 +70,10 @@ (progn (eval '(defmethod dmc-gf-03 ((x integer)) t)) :bad) - (error () :good)) + (error () + (dolist (meth (compute-applicable-methods #'dmc-gf-03 (list 1))) + (remove-method #'dmc-gf-03 meth)) + :good)) :good) (deftest define-method-combination-03.2 @@ -64,7 +81,10 @@ (progn (eval '(defmethod dmc-gf-03 :before ((x cons)) t)) :bad) - (error () :good)) + (error () + (dolist (meth (compute-applicable-methods #'dmc-gf-03 (list '(a)))) + (remove-method #'dmc-gf-03 meth)) + :good)) :good) (deftest define-method-combination-03.3 @@ -72,16 +92,31 @@ (progn (eval '(defmethod dmc-gf-03 :after ((x symbol)) t)) :bad) - (error () :good)) + (error () + (dolist (meth (compute-applicable-methods #'dmc-gf-03 (list 'a))) + (remove-method #'dmc-gf-03 meth)) + :good)) :good) +(define-method-combination times2 + :operator * + :identity-with-one-argument t) +(defgeneric dmc-gf-04 (x) (:method-combination times2)) +(defmethod dmc-gf-04 times2 ((x dmc-class-01b)) 2) +(defmethod dmc-gf-04 times2 ((x dmc-class-01c)) 3) +(defmethod dmc-gf-04 times2 ((x dmc-class-01d)) 5) +(defmethod dmc-gf-04 times2 ((x symbol)) nil) +(deftest define-method-combination-04.1 + (dmc-gf-04 (make-instance 'dmc-class-01h)) + 30) +(deftest define-method-combination-04.2 + (dmc-gf-04 (make-instance 'dmc-class-01e)) + 6) - - - - - +(deftest define-method-combination-04.3 + (dmc-gf-04 'a) + nil) -- GitLab