summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/cl-macs-tests.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2021-04-07 11:31:07 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2021-04-15 15:41:13 +0200
commit7893945cc8f9421d0be5b07b9ed404bdf25ce140 (patch)
tree1e3740a75827ed18c542f41b88ca9013120b3920 /test/lisp/emacs-lisp/cl-macs-tests.el
parent31f8ae53beb9bada58750160c1bf7f867ecd442e (diff)
downloademacs-7893945cc8f9421d0be5b07b9ed404bdf25ce140.tar.gz
Add condition-case success handler (bug#47677)
Allow a condition-case handler on the form (:success BODY) to be specified as the success continuation of the protected form, with the specified variable bound to its result. * src/eval.c (Fcondition_case): Update the doc string. (internal_lisp_condition_case): Implement in interpreter. (syms_of_eval): Defsym :success. * lisp/emacs-lisp/bytecomp.el (byte-compile-condition-case): Implement in byte-compiler. * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Allow self-TCO from success handler. * doc/lispref/control.texi (Handling Errors): Update manual. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases) (bytecomp-condition-case-success): * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test cases.
Diffstat (limited to 'test/lisp/emacs-lisp/cl-macs-tests.el')
-rw-r--r--test/lisp/emacs-lisp/cl-macs-tests.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el
index 5c3e603b92e..f4e2e46a019 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -630,12 +630,13 @@ collection clause."
(and xs
(progn (setq n1 (1+ n))
(len2 (cdr xs) n1))))))
- ;; Tail call in error handler.
+ ;; Tail calls in error and success handlers.
(len3 (xs n)
(if xs
- (condition-case nil
- (/ 1 0)
- (arith-error (len3 (cdr xs) (1+ n))))
+ (condition-case k
+ (/ 1 (logand n 1))
+ (arith-error (len3 (cdr xs) (1+ n)))
+ (:success (len3 (cdr xs) (+ n k))))
n)))
(should (equal (len nil 0) 0))
(should (equal (len2 nil 0) 0))