X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcondition.impure.lisp;h=ae332c30ff63d941196077dd97378657675bceda;hb=9bdd2579f980573a74daabe03120ed64b1733b11;hp=b66ed3f76372148db434f2d6a8936e3e98973016;hpb=f37fd916aae6ecbb7341c1385c7113608b7816a5;p=sbcl.git diff --git a/tests/condition.impure.lisp b/tests/condition.impure.lisp index b66ed3f..ae332c3 100644 --- a/tests/condition.impure.lisp +++ b/tests/condition.impure.lisp @@ -96,22 +96,23 @@ (define-condition my-stream-error-1-0-9 (stream-error) ()) (define-condition parse-foo-error-1-0-9 (parse-error) ()) (define-condition read-bar-error-1-0-9 (reader-error) ()) -(let (;; instances created initializing all the slots specified in - ;; ANSI CL - (parse-foo-error-1-0-9 (make-condition 'parse-foo-error-1-0-9 - :stream *standard-input*)) - (read-foo-error-1-0-9 (make-condition 'read-bar-error-1-0-9 - :stream *standard-input*)) - (my-stream-error-1-0-9 (make-condition 'my-stream-error-1-0-9 - :stream *standard-input*))) - ;; should be printable - (dolist (c (list - my-stream-error-1-0-9 - parse-foo-error-1-0-9 - read-foo-error-1-0-9)) - ;; whether escaped or not - (dolist (*print-escape* '(nil t)) - (write c :stream (make-string-output-stream))))) +(with-test (:name :printable-conditions) + (let (;; instances created initializing all the slots specified in + ;; ANSI CL + (parse-foo-error-1-0-9 (make-condition 'parse-foo-error-1-0-9 + :stream *standard-input*)) + (read-foo-error-1-0-9 (make-condition 'read-bar-error-1-0-9 + :stream *standard-input*)) + (my-stream-error-1-0-9 (make-condition 'my-stream-error-1-0-9 + :stream *standard-input*))) + ;; should be printable + (dolist (c (list + my-stream-error-1-0-9 + parse-foo-error-1-0-9 + read-foo-error-1-0-9)) + ;; whether escaped or not + (dolist (*print-escape* '(nil t)) + (write c :stream (make-string-output-stream)))))) ;;; Reported by Michael Weber: restart computation in :TEST-FUNCTION used to ;;; cause infinite recursion. @@ -121,6 +122,7 @@ (return-from restart-test-finds-restarts 42)) :test-function (lambda (condition) + (declare (ignore condition)) (find-restart 'qux)))) (when (find-restart 'bar) (invoke-restart 'bar)))) @@ -135,3 +137,59 @@ ((slot :initarg :slot :reader ,reader)) (:report (lambda (c stream) (format stream "Oops: ~S" (,reader c)))))))))) + +(with-test (:name :define-condition-result) + (let ((name (gensym "CONDITION"))) + (assert + (eq (eval `(define-condition ,name () ())) + name)))) + +;;; bug-1164970 + +(define-condition condition-with-default-initargs (condition) + () + (:default-initargs :foo 1)) + +(with-test (:name (sb-mop:class-direct-default-initargs :for-condition-class + :bug-1164970)) + ;; CLASS-DIRECT-DEFAULT-INITARGS used to return nil for all + ;; condition classes. + (let ((initargs (sb-mop:class-direct-default-initargs + (find-class 'condition-with-default-initargs)))) + (assert (equal (subseq (first initargs) 0 2) '(:foo 1))))) + +;;; bug-539517 + +(defconstant +error-when-called+ (lambda () (error "oops"))) + +(define-condition condition-with-constant-function-initarg () + ((foo :initarg :foo + :reader condition-with-constant-function-initarg-foo)) + (:default-initargs :foo +error-when-called+)) + +(with-test (:name (:condition-with-constant-function-initarg :bug-539517)) + ;; The default initarg handling for condition classes used to + ;; confuse constant functions (thus +ERROR-WHEN-CALLED+) and + ;; initfunctions. This lead to +ERROR-WHEN-CALLED+ being called as + ;; if it was an initfunction. + (assert (functionp + (condition-with-constant-function-initarg-foo + (make-condition 'condition-with-constant-function-initarg)))) + (assert (functionp + (condition-with-constant-function-initarg-foo + (make-instance 'condition-with-constant-function-initarg))))) + +;; Same problem + +(define-condition condition-with-constant-function-initform () + ((foo :initarg :foo + :reader condition-with-constant-function-initform-foo + :initform +error-when-called+))) + +(with-test (:name (:condition-with-constant-function-slot-initform)) + (assert (functionp + (condition-with-constant-function-initform-foo + (make-condition 'condition-with-constant-function-initform)))) + (assert (functionp + (condition-with-constant-function-initform-foo + (make-instance 'condition-with-constant-function-initform)))))