aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-06-28 19:54:37 +0800
committerMistivia <i@mistivia.com>2025-06-28 19:54:37 +0800
commit9a4f460d6dd476767ea211c879f115e127ee2410 (patch)
tree8a7ad58e670065af74c261f51f5f21e9bfec3615 /tests
parent0633c6c2797bc9182b2c1888385eac6cb6caed10 (diff)
exception & try-catch
Diffstat (limited to 'tests')
-rw-r--r--tests/error.lisp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/error.lisp b/tests/error.lisp
index c774622..4cfd8a3 100644
--- a/tests/error.lisp
+++ b/tests/error.lisp
@@ -9,3 +9,23 @@
(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))