invoke-debugger.lsp 1.96 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Fri Feb 28 21:59:57 2003
;;;; Contains: Tests of INVOKE-DEBUGGER

6

7 8 9 10 11 12 13 14

;;; We can't test actual entry into the debugger, but we can test
;;; that the function in *debugger-hook* is properly called.

(deftest invoke-debugger.1
  (block done
   (let (fn (cnd (make-condition 'simple-error)))
       (setq fn #'(lambda (c hook)
sds's avatar
sds committed
15 16 17 18 19
                    (return-from done
                      (and (null *debugger-hook*)
                           (eqt hook fn)
                           (eqt cnd c)
                           'good))))
20
       (let ((*debugger-hook* fn))
sds's avatar
sds committed
21
         (invoke-debugger cnd)))
22 23
   'bad)
  good)
24 25

(deftest invoke-debugger.error.1
26
  (signals-error
27 28
   (block done
     (let ((*debugger-hook* #'(lambda (&rest args)
sds's avatar
sds committed
29 30
                                (declare (ignore args))
                                (return-from done 'bad))))
31 32 33
       (invoke-debugger)))
   program-error)
  t)
34 35

(deftest invoke-debugger.error.2
36
  (signals-error
37 38
   (block done
     (let ((*debugger-hook* #'(lambda (&rest args)
sds's avatar
sds committed
39 40
                                (declare (ignore args))
                                (return-from done 'bad))))
41 42 43
       (invoke-debugger (make-condition 'simple-error) nil)))
   program-error)
  t)
44 45 46 47 48 49

;;; If the debugger hook function expects the wrong number
;;; of arguments, a program-error should be thrown in safe code
;;; This error is thrown 'prior to entry to the standard debugger'.

(deftest invoke-debugger.error.3
50
  (signals-error
51
   (let ((*debugger-hook* #'(lambda () nil)))
52 53 54
     (invoke-debugger (make-condition 'simple-error)))
   program-error)
  t)
55 56

(deftest invoke-debugger.error.4
57
  (signals-error
58
   (let ((*debugger-hook* #'(lambda (c) c)))
59 60 61
     (invoke-debugger (make-condition 'simple-error)))
   program-error)
  t)
62 63

(deftest invoke-debugger.error.5
64
  (signals-error
65
   (let ((*debugger-hook* #'(lambda (c hook x) (list c hook x))))
66 67 68
     (invoke-debugger (make-condition 'simple-error)))
   program-error)
  t)