X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fclos.impure.lisp;h=cf876d9249dccffee1de3fa7a0b0e9affa9cc8c6;hb=219cc40793f9c82fb943b29a1846f898f4f9de1e;hp=91eab018bc1ab08d224c89e4fd4295ec259f58ef;hpb=90c4b36715e7173e12fe4af1079a347b2e6fd14b;p=sbcl.git diff --git a/tests/clos.impure.lisp b/tests/clos.impure.lisp index 91eab01..cf876d9 100644 --- a/tests/clos.impure.lisp +++ b/tests/clos.impure.lisp @@ -356,10 +356,14 @@ ;;; DOCUMENTATION's argument-precedence-order wasn't being faithfully ;;; preserved through the bootstrap process until sbcl-0.7.8.39. ;;; (thanks to Gerd Moellmann) -(let ((answer (documentation '+ 'function))) - (assert (stringp answer)) - (defmethod documentation ((x (eql '+)) y) "WRONG") - (assert (string= (documentation '+ 'function) answer))) +(with-test (:name :documentation-argument-precedence-order) + (defun foo022 () + "Documentation" + t) + (let ((answer (documentation 'foo022 'function))) + (assert (stringp answer)) + (defmethod documentation ((x (eql 'foo022)) y) "WRONG") + (assert (string= (documentation 'foo022 'function) answer)))) ;;; only certain declarations are permitted in DEFGENERIC (macrolet ((assert-program-error (form) @@ -1112,7 +1116,9 @@ (assert (= (method-on-defined-type-and-class 3) 4))))) ;; bug 281 -(let ((sb-pcl::*max-emf-precomputation-methods* 0)) +(let (#+nil ; no more sb-pcl::*max-emf-precomputation-methods* as of + ; sbcl-1.0.41.x + (sb-pcl::*max-emf-precomputation-methods* 0)) (eval '(defgeneric bug-281 (x) (:method-combination +) (:method ((x symbol)) 1) @@ -1833,5 +1839,66 @@ "ok!")) (invoke-restart r)))))) (no-primary-method/retry (cons t t)))))) + +;;; test that a cacheing strategy for make-instance initargs checking +;;; can handle class redefinitions +(defclass cacheing-initargs-redefinitions-check () + ((slot :initarg :slot))) +(defun cacheing-initargs-redefinitions-check-fun (&optional (initarg :slot)) + (declare (notinline make-instance)) + (make-instance 'cacheing-initargs-redefinitions-check) + (make-instance 'cacheing-initargs-redefinitions-check initarg 3)) +(with-test (:name :make-instance-initargs) + (make-instance 'cacheing-initargs-redefinitions-check) + (make-instance 'cacheing-initargs-redefinitions-check :slot 3) + (cacheing-initargs-redefinitions-check-fun :slot) + (assert (raises-error? (cacheing-initargs-redefinitions-check-fun :slot2)))) +(defclass cacheing-initargs-redefinitions-check () + ((slot :initarg :slot2))) +(with-test (:name :make-instance-redefined-initargs) + (make-instance 'cacheing-initargs-redefinitions-check) + (make-instance 'cacheing-initargs-redefinitions-check :slot2 3) + (cacheing-initargs-redefinitions-check-fun :slot2) + (assert (raises-error? (cacheing-initargs-redefinitions-check-fun :slot)))) +(defmethod initialize-instance :after ((class cacheing-initargs-redefinitions-check) &key slot) + nil) +(with-test (:name :make-instance-new-method-initargs) + (make-instance 'cacheing-initargs-redefinitions-check) + (make-instance 'cacheing-initargs-redefinitions-check :slot2 3) + (cacheing-initargs-redefinitions-check-fun :slot2) + (let ((thing (cacheing-initargs-redefinitions-check-fun :slot))) + (assert (not (slot-boundp thing 'slot))))) + +(with-test (:name :defmethod-specializer-builtin-class-alias) + (let ((alias (gensym))) + (setf (find-class alias) (find-class 'symbol)) + (eval `(defmethod lp-618387 ((s ,alias)) + (symbol-name s))) + (assert (equal "FOO" (funcall 'lp-618387 :foo))))) + +(with-test (:name :pcl-spurious-ignore-warnings) + (defgeneric no-spurious-ignore-warnings (req &key key)) + (handler-bind ((warning (lambda (x) (error "~A" x)))) + (eval + '(defmethod no-spurious-ignore-warnings ((req number) &key key) + (declare (ignore key)) + (check-type req integer)))) + (defgeneric should-get-an-ignore-warning (req &key key)) + (let ((warnings 0)) + (handler-bind ((warning (lambda (c) (setq warnings 1) (muffle-warning c)))) + (eval '(defmethod should-get-an-ignore-warning ((req integer) &key key) + (check-type req integer)))) + (assert (= warnings 1)))) + +(defgeneric generic-function-pretty-arglist-optional-and-key (req &optional opt &key key) + (:method (req &optional opt &key key) + (list req opt key))) + +(with-test (:name :generic-function-pretty-arglist-optional-and-key) + (handler-bind ((warning #'error)) + ;; Used to signal a style-warning + (assert (equal '(req &optional opt &key key) + (sb-pcl::generic-function-pretty-arglist + #'generic-function-pretty-arglist-optional-and-key))))) ;;;; success