X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fclos.impure-cload.lisp;h=67032c54047bb4a3d96c75945023a912ccb7cad5;hb=e0ba0f10da0a0f2722494bd2dd9646f0b5a44d75;hp=f0a18296f0104462453728afabf091336bd0eb20;hpb=394ea85ef47f8b145437e1498266487c4f96f285;p=sbcl.git diff --git a/tests/clos.impure-cload.lisp b/tests/clos.impure-cload.lisp index f0a1829..67032c5 100644 --- a/tests/clos.impure-cload.lisp +++ b/tests/clos.impure-cload.lisp @@ -63,6 +63,13 @@ (defmethod baz ((x specializer1)) x) (assert (typep (baz (make-instance 'specializer1)) 'specializer1)) +;;; ... and from McCLIM, another test case: +(defclass specializer1a (specializer2a specializer2b) ()) +(defclass specializer2a () ()) +(defmethod initialize-instance :after + ((obj specializer2a) &key &allow-other-keys) + (print obj)) + ;;; in a similar vein, we should be able to define methods on classes ;;; that are effectively unknown to the type system: (sb-mop:ensure-class 'unknown-type) @@ -71,7 +78,7 @@ ;;; etc., but we should be able to define it). ;;; the ctor MAKE-INSTANCE optimizer used not to handle duplicate -;;; initargs. +;;; initargs... (defclass dinitargs-class1 () ((a :initarg :a))) (assert (= (slot-value (make-instance 'dinitargs-class1 :a 1 :a 2) 'a) 1)) @@ -79,6 +86,24 @@ (defclass dinitargs-class2 () ((b :initarg :b1 :initarg :b2))) (assert (= (slot-value (make-instance 'dinitargs-class2 :b2 3 :b1 4) 'b) 3)) +;;; ... or default-initargs when the location was already initialized +(defvar *definitargs-counter* 0) +(defclass definitargs-class () + ((a :initarg :a :initarg :a2)) + (:default-initargs :a2 (incf *definitargs-counter*))) +(assert (= (slot-value (make-instance 'definitargs-class) 'a) 1)) +(assert (= (slot-value (make-instance 'definitargs-class :a 0) 'a) 0)) +(assert (= *definitargs-counter* 2)) + +;;; inherited local -> shared slot initforms +;; (adapted from Paul F. Dietz's test suite DEFCLASS-0211.1) +(defclass shared-to-local-initform-super () + ((redefined :allocation :instance :initform 'orig-initform))) +(defclass shared-to-local-initform-sub (shared-to-local-initform-super) + ((redefined :allocation :class))) +(assert (slot-boundp (make-instance 'shared-to-local-initform-sub) 'redefined)) +(assert (eq 'orig-initform + (slot-value (make-instance 'shared-to-local-initform-sub) 'redefined))) ;;; success (sb-ext:quit :unix-status 104) \ No newline at end of file