make-condition.lsp 1.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Jun 23 11:54:10 2005
;;;; Contains: Tests of MAKE-CONDITION

(in-package :cl-test)


(deftest make-condition.1
  (loop for tp in *cl-condition-type-symbols*
sds's avatar
sds committed
11 12 13 14
        for c = (make-condition tp)
        unless (and (typep c tp)
                    (typep c 'condition))
        collect (list tp c))
15 16 17 18
  nil)

(deftest make-condition.2
  (loop for tp in *cl-condition-type-symbols*
sds's avatar
sds committed
19 20 21 22 23 24 25
        for class = (find-class tp)
        for c = (and class (make-condition class))
        unless (or (not class)
                   (and (typep c tp)
                        (typep c class)
                        (typep c 'condition)))
        collect (list tp c))
26 27 28
  nil)

(deftest make-condition.3
29
  :notes (:make-condition-with-compound-name :ansi-spec-problem)
30
  (let* ((tp '(or program-error type-error))
sds's avatar
sds committed
31
         (c (make-condition tp)))
32
    (or (not (and (subtypep tp 'condition)
sds's avatar
sds committed
33 34 35
                  (or (subtypep 'program-error tp)
                      (subtypep 'type-error tp))))
        (notnot-mv (typep c tp))))
36 37 38
  t)

(deftest make-condition.4
39
  :notes (:make-condition-with-compound-name :ansi-spec-problem)
40
  (let* ((tp '(and simple-error type-error))
sds's avatar
sds committed
41
         (c (make-condition tp)))
42
    (or (not (and (subtypep 'simple-error tp)
sds's avatar
sds committed
43 44 45
                  (subtypep 'type-error tp)
                  (subtypep tp 'condition)))
        (notnot-mv (typep c tp))))
46 47 48 49 50 51 52
  t)

;;; Error tests

(deftest make-condition.error.1
  (signals-error (make-condition) program-error)
  t)