X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fclos.impure.lisp;h=100407d0beacafc4fdb4466ac2274a15077d0e00;hb=7a7a5268d45a213d425228e87c9ecc9f79bd7858;hp=de4c435f333aa7f49291b9f862e17f68404f62ba;hpb=175c318c892b0627b36fa3c4db66f59680242204;p=sbcl.git diff --git a/tests/clos.impure.lisp b/tests/clos.impure.lisp index de4c435..100407d 100644 --- a/tests/clos.impure.lisp +++ b/tests/clos.impure.lisp @@ -14,7 +14,7 @@ (load "assertoid.lisp") (defpackage "CLOS-IMPURE" - (:use "CL" "ASSERTOID")) + (:use "CL" "ASSERTOID" "TEST-UTIL")) (in-package "CLOS-IMPURE") ;;; It should be possible to do DEFGENERIC and DEFMETHOD referring to @@ -892,6 +892,28 @@ (slot-boundp *obsoleted* 'a) (assert (= *obsoleted-counter* 1)) +;;; yet another MAKE-INSTANCES-OBSOLETE test, this time from Nikodemus +;;; Siivola. Not all methods for accessing slots are created equal... +(defclass yet-another-obsoletion-super () ((obs :accessor obs-of :initform 0))) +(defclass yet-another-obsoletion-sub (yet-another-obsoletion-super) ()) +(defmethod shared-initialize :after ((i yet-another-obsoletion-super) + slots &rest init) + (incf (obs-of i))) + +(defvar *yao-super* (make-instance 'yet-another-obsoletion-super)) +(defvar *yao-sub* (make-instance 'yet-another-obsoletion-sub)) + +(assert (= (obs-of *yao-super*) 1)) +(assert (= (obs-of *yao-sub*) 1)) +(make-instances-obsolete 'yet-another-obsoletion-super) +(assert (= (obs-of *yao-sub*) 2)) +(assert (= (obs-of *yao-super*) 2)) +(make-instances-obsolete 'yet-another-obsoletion-super) +(assert (= (obs-of *yao-super*) 3)) +(assert (= (obs-of *yao-sub*) 3)) +(assert (= (slot-value *yao-super* 'obs) 3)) +(assert (= (slot-value *yao-sub* 'obs) 3)) + ;;; shared -> local slot transfers of inherited slots, reported by ;;; Bruno Haible (let (i) @@ -1177,5 +1199,36 @@ (assert (equal (list (slot-value c1 'class-slot) (slot-value c2 'class-slot)) (list 1 1)))))) - + +;;; tests of ctors on anonymous classes +(defparameter *unnamed* (defclass ctor-unnamed-literal-class () ())) +(setf (class-name *unnamed*) nil) +(setf (find-class 'ctor-unnamed-literal-class) nil) +(defparameter *unnamed2* (defclass ctor-unnamed-literal-class2 () ())) +(defun ctor-unnamed-literal-class () + (make-instance '#.*unnamed*)) +(compile 'ctor-unnamed-literal-class) +(defun ctor-unnamed-literal-class2 () + (make-instance '#.(find-class 'ctor-unnamed-literal-class2))) +(compile 'ctor-unnamed-literal-class2) +(defun ctor-unnamed-literal-class2/symbol () + (make-instance 'ctor-unnamed-literal-class2)) +(compile 'ctor-unnamed-literal-class2/symbol) +(setf (class-name *unnamed2*) nil) +(setf (find-class 'ctor-unnamed-literal-class2) nil) +(with-test (:name (:ctor :unnamed-before)) + (assert (typep (ctor-unnamed-literal-class) *unnamed*))) +(with-test (:name (:ctor :unnamed-after)) + (assert (typep (ctor-unnamed-literal-class2) *unnamed2*))) +(with-test (:name (:ctor :unnamed-after/symbol)) + (assert (raises-error? (ctor-unnamed-literal-class2/symbol)))) + +;;; classes with slot types shouldn't break if the types don't name +;;; classes (bug #391) +(defclass slot-type-superclass () ((slot :type fixnum))) +(defclass slot-type-subclass (slot-type-superclass) + ((slot :type (integer 1 5)))) +(let ((instance (make-instance 'slot-type-subclass))) + (setf (slot-value instance 'slot) 3)) + ;;;; success