error.lsp 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 28 21:37:43 2003
;;;; Contains: Tests of ERROR

(in-package :cl-test)

(deftest error.1
  (let ((fmt "Error"))
10 11 12
    (handler-case
     (error fmt)
     (simple-error (c) (frob-simple-error c fmt))))
13 14 15 16
  t)

(deftest error.2
  (let* ((fmt "Error")
sds's avatar
sds committed
17
         (cnd (make-condition 'simple-error :format-control fmt)))
18 19 20
    (handler-case
     (error cnd)
     (simple-error (c) (frob-simple-error c fmt))))
21 22 23 24
  t)

(deftest error.3
  (let ((fmt "Error"))
25 26 27
    (handler-case
     (error 'simple-error :format-control fmt)
     (simple-error (c) (frob-simple-error c fmt))))
28 29
  t)

30 31
(deftest error.4
  (let ((fmt "Error: ~A"))
32 33 34
    (handler-case
     (error fmt 10)
     (simple-error (c) (frob-simple-error c fmt 10))))
35 36 37 38
  t)

(deftest error.5
  (let ((fmt (formatter "Error")))
39 40 41
    (handler-case
     (error fmt)
     (simple-error (c) (frob-simple-error c fmt))))
42
  t)
pfdietz's avatar
pfdietz committed
43 44 45 46

(deftest error.6
  (handler-case
   (error 'simple-condition)
47 48
   (error (c) (declare (ignore c)) :wrong)
   (simple-condition (c) (declare (ignore c)) :right))
pfdietz's avatar
pfdietz committed
49 50 51 52 53
  :right)

(deftest error.7
  (handler-case
   (error 'simple-warning)
54 55 56
   (error (c) (declare (ignore c)) :wrong)
   (simple-warning (c) (declare (ignore c)) :right)
   (condition (c) (declare (ignore c)) :wrong2))
pfdietz's avatar
pfdietz committed
57 58 59 60 61 62 63 64 65
  :right)

(deftest error.8
  (let ((fmt "Boo!"))
    (handler-case
     (error 'simple-warning :format-control fmt)
     (simple-warning (c) (frob-simple-warning c fmt))))
  t)

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
(deftest error.9
  (let ((fmt (formatter "Boo!")))
    (handler-case
     (error 'simple-warning :format-control fmt)
     (simple-warning (c) (frob-simple-warning c fmt))))
  t)

(deftest error.10
  (let ((fmt (formatter "Error")))
    (handler-case
     (error 'simple-error :format-control fmt)
     (simple-error (c) (frob-simple-error c fmt))))
  t)

(deftest error.11
  (let ((fmt (formatter "Error")))
    (handler-case
     (error fmt)
     (simple-error (c) (frob-simple-error c fmt))))
  t)

(deftest error.12
  (let* ((fmt (formatter "Error"))
sds's avatar
sds committed
89
         (cnd (make-condition 'simple-error :format-control fmt)))
90 91 92 93 94
    (handler-case
     (error cnd)
     (simple-error (c) (frob-simple-error c fmt))))
  t)

pfdietz's avatar
pfdietz committed
95
;;; Tests for other conditions will in their own files.