aboutsummaryrefslogtreecommitdiff
path: root/tests/error.lisp
blob: 4cfd8a3f77ade6a36ffe852385d8ea5b09eef576 (plain)
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
(assert-error (error ""))
(assert-error (let ((x (error ""))) #t))
(assert-error (let () (error "") #t))
(assert-error (if (error "") #t #t))
(assert-error (and (error "")))
(assert-error (or (error "")))
(assert-error (funcall (lambda () (error ""))))
(assert-error (while #t (error "")))
(assert-error (cond (#t (error ""))))
(assert-error (cond ((error "") #t)))

(assert-exception (throw ""))
(assert-exception (let ((x (throw ""))) #t))
(assert-exception (let () (throw "") #t))
(assert-exception (if (throw "") #t #t))
(assert-exception (and (throw "")))
(assert-exception (or (throw "")))
(assert-exception (funcall (lambda () (throw ""))))
(assert-exception (while #t (throw "")))
(assert-exception (cond (#t (throw ""))))
(assert-exception (cond ((throw "") #t)))

(defvar flag 1)
(try 
  (let ()
    (+ 1 2)
    (throw 42))
  (lambda (e)
    (assert (= e 42))
    (setq flag 0)))
(assert (= flag 0))