X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fclos.impure-cload.lisp;h=d5d8c30798f992a7fad316b00c2063e9ade7bb20;hb=062283b901155792f65775491aea51481c56faaa;hp=26dd5948e0d6ce4555b423dda0840ecac90e5aa1;hpb=efea157110a4db2595f154234641b6768185c307;p=sbcl.git diff --git a/tests/clos.impure-cload.lisp b/tests/clos.impure-cload.lisp index 26dd594..d5d8c30 100644 --- a/tests/clos.impure-cload.lisp +++ b/tests/clos.impure-cload.lisp @@ -7,7 +7,7 @@ ;;;; While most of SBCL is derived from the CMU CL system, the test ;;;; files (like this one) were written from scratch after the fork ;;;; from CMU CL. -;;;; +;;;; ;;;; This software is in the public domain and is provided with ;;;; absolutely no warranty. See the COPYING and CREDITS files for ;;;; more information. @@ -103,30 +103,60 @@ ((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))) + (slot-value (make-instance 'shared-to-local-initform-sub) 'redefined))) (defgeneric no-ignored-warnings (x y)) (handler-case (eval '(defmethod no-ignored-warnings ((x t) (y t)) - (declare (ignore x y)) nil)) + (declare (ignore x y)) nil)) (style-warning (c) (error c))) (handler-case (eval '(defmethod no-ignored-warnings ((x number) (y t)) - (declare (ignore x y)) (setq *print-level* nil))) + (declare (ignore x y)) (setq *print-level* nil))) (style-warning (c) (error c))) (handler-case (eval '(defmethod no-ignored-warnings ((x fixnum) (y t)) - (declare (ignore x)) (setq y 'foo))) + (declare (ignore x)) (setq y 'foo))) (style-warning (c) (error c))) +;;; ctor optimization bugs: +;;; +;;; :DEFAULT-INITARGS not checked for validity +(defclass invalid-default-initargs () + ((foo :initarg :foo)) + (:default-initargs :invalid-initarg 2)) +(multiple-value-bind (result condition) + (ignore-errors (make-instance 'invalid-default-initargs :foo 1)) + (assert (null result)) + (assert (typep condition 'program-error))) +;;; :DEFAULT-INITARGS not passed to INITIALIZE-INSTANCE or +;;; SHARED-INITIALIZE :BEFORE methods. +(defclass default-initargs-with-method () + ((foo :initarg :valid-initarg)) + (:default-initargs :valid-initarg 2)) +(defmethod shared-initialize :before ((thing default-initargs-with-method) + slot-names &key valid-initarg) + (assert (= valid-initarg 2))) +(make-instance 'default-initargs-with-method) +;;; and a test with a non-constant initarg +(defvar *d-i-w-m-2* 0) +(defclass default-initargs-with-method2 () + ((foo :initarg :valid-initarg)) + (:default-initargs :valid-initarg (incf *d-i-w-m-2*))) +(defmethod shared-initialize :before ((thing default-initargs-with-method2) + slot-names &key valid-initarg) + (assert (= valid-initarg 1))) +(make-instance 'default-initargs-with-method2) +(assert (= *d-i-w-m-2* 1)) + ;;; from Axel Schairer on cmucl-imp 2004-08-05 (defclass class-with-symbol-initarg () ((slot :initarg slot))) (defmethod initialize-instance :after ((x class-with-symbol-initarg) &rest initargs &key &allow-other-keys) (unless (or (null initargs) - (eql (getf initargs 'slot) - (slot-value x 'slot))) + (eql (getf initargs 'slot) + (slot-value x 'slot))) (error "bad bad bad"))) (defun make-thing (arg) (make-instance 'class-with-symbol-initarg 'slot arg)) @@ -135,5 +165,22 @@ (assert (eql (slot-value (make-thing 1) 'slot) 1)) (assert (eql (slot-value (make-other-thing 'slot 2) 'slot) 2)) -;;; success -(sb-ext:quit :unix-status 104) +;;; test that ctors can be used with the literal class +(eval-when (:compile-toplevel) + (defclass ctor-literal-class () ()) + (defclass ctor-literal-class2 () ())) +(defun ctor-literal-class () + (make-instance #.(find-class 'ctor-literal-class))) +(defun ctor-literal-class2 () + (make-instance '#.(find-class 'ctor-literal-class2))) +(with-test (:name (:ctor :literal-class-unquoted)) + (assert (typep (ctor-literal-class) 'ctor-literal-class))) +(with-test (:name (:ctor :literal-class-quoted)) + (assert (typep (ctor-literal-class2) 'ctor-literal-class2))) + +;;; test that call-next-method and eval-when doesn't cause an +;;; undumpable method object to arise in the effective source code. +;;; (from Sascha Wilde sbcl-devel 2007-07-15) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defmethod just-call-next-method (thing) + (call-next-method)))