File: invoke-debugger.lsp

package info (click to toggle)
cl-ansi-tests 20071218-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,000 kB
  • ctags: 22,025
  • sloc: lisp: 134,798; makefile: 144
file content (68 lines) | stat: -rw-r--r-- 1,823 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Fri Feb 28 21:59:57 2003
;;;; Contains: Tests of INVOKE-DEBUGGER

(in-package :cl-test)

;;; 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)
		    (return-from done
		      (and (null *debugger-hook*)
			   (eqt hook fn)
			   (eqt cnd c)
			   'good))))
       (let ((*debugger-hook* fn))
	 (invoke-debugger cnd)))
   'bad)
  good)

(deftest invoke-debugger.error.1
  (signals-error
   (block done
     (let ((*debugger-hook* #'(lambda (&rest args)
				(declare (ignore args))
				(return-from done 'bad))))
       (invoke-debugger)))
   program-error)
  t)

(deftest invoke-debugger.error.2
  (signals-error
   (block done
     (let ((*debugger-hook* #'(lambda (&rest args)
				(declare (ignore args))
				(return-from done 'bad))))
       (invoke-debugger (make-condition 'simple-error) nil)))
   program-error)
  t)

;;; 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
  (signals-error
   (let ((*debugger-hook* #'(lambda () nil)))
     (invoke-debugger (make-condition 'simple-error)))
   program-error)
  t)

(deftest invoke-debugger.error.4
  (signals-error
   (let ((*debugger-hook* #'(lambda (c) c)))
     (invoke-debugger (make-condition 'simple-error)))
   program-error)
  t)

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