cerror.lsp 1.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Feb 15 19:45:27 2003
;;;; Contains: Tests of CERROR


(in-package :cl-test)

(deftest cerror.1
  (let ((fmt "Cerror"))
    (handler-case (cerror "Keep going." fmt)
sds's avatar
sds committed
12
                  (simple-error (c) (frob-simple-error c fmt))))
13 14 15 16
  t)

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

22 23
(deftest cerror.2a
  (let* ((fmt (formatter "Cerror"))
sds's avatar
sds committed
24
         (cnd (make-condition 'simple-error :format-control fmt)))
25
    (handler-case (cerror "Continue on." cnd)
sds's avatar
sds committed
26
                  (simple-error (c) (frob-simple-error c fmt))))
27 28
  t)

29 30 31
(deftest cerror.3
  (let ((fmt "Cerror"))
    (handler-case (cerror "Continue" 'simple-error :format-control fmt)
sds's avatar
sds committed
32
                  (simple-error (c) (frob-simple-error c fmt))))
33 34 35 36 37
  t)

(deftest cerror.4
  (let ((fmt "Cerror: ~A"))
    (handler-case (cerror "On on" fmt 10)
sds's avatar
sds committed
38
                  (simple-error (c) (frob-simple-error c fmt 10))))
39 40
  t)

41 42 43
(deftest cerror.4a
  (let ((fmt (formatter "Cerror: ~A")))
    (handler-case (cerror "On on" fmt 10)
sds's avatar
sds committed
44
                  (simple-error (c) (frob-simple-error c fmt 10))))
45 46
  t)

47 48 49
(deftest cerror.5
  (let ((fmt (formatter "Cerror")))
    (handler-case (cerror "Keep going." fmt)
sds's avatar
sds committed
50
                  (simple-error (c) (frob-simple-error c fmt))))
51 52 53 54 55 56
  t)

;;; Continuing from a cerror

(deftest cerror.6
  (handler-bind ((simple-error #'(lambda (c) (continue c))))
sds's avatar
sds committed
57 58 59
                (progn
                  (cerror "Wooo" 'simple-error)
                  10))
60
  10)
61

62
;;; Program error cases
63 64

(deftest cerror.error.1
65 66
  (signals-error (cerror) program-error)
  t)
67 68

(deftest cerror.error.2
69 70 71
  (signals-error (cerror "foo") program-error)
  t)