emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/handler-bind 1c1d2eb3e38 03/10: Use handler-bind to repair bytec


From: Stefan Monnier
Subject: scratch/handler-bind 1c1d2eb3e38 03/10: Use handler-bind to repair bytecomp-tests
Date: Thu, 28 Dec 2023 01:01:05 -0500 (EST)

branch: scratch/handler-bind
commit 1c1d2eb3e389bb5e397cd8e1568e4e3129067912
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Use handler-bind to repair bytecomp-tests
    
    * test/lisp/emacs-lisp/bytecomp-tests.el
    (bytecomp-tests--error-frame, bytecomp--byte-op-error-backtrace):
    Make test pass again and simplify, using handler-bind instead
    of the previous debugger hack.
---
 test/lisp/emacs-lisp/bytecomp-tests.el | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el 
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 8fbe48bbb9a..f4cefaaac92 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -2087,18 +2087,12 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode 
js-mode python-mode)) \
 
 (defun bytecomp-tests--error-frame (fun args)
   "Call FUN with ARGS.  Return result or (ERROR . BACKTRACE-FRAME)."
-  (let* ((debugger
-          (lambda (&rest args)
-            ;; Make sure Emacs doesn't think our debugger is buggy.
-            (cl-incf num-nonmacro-input-events)
-            (throw 'bytecomp-tests--backtrace
-                   (cons args (cadr (backtrace-get-frames debugger))))))
-         (debug-on-error t)
-         (backtrace-on-error-noninteractive nil)
-         (debug-on-quit t)
-         (debug-ignored-errors nil))
+  (letrec ((handler (lambda (e)
+                      (throw 'bytecomp-tests--backtrace
+                             (cons e (cadr (backtrace-get-frames handler)))))))
     (catch 'bytecomp-tests--backtrace
-      (apply fun args))))
+      (handler-bind ((error handler))
+        (apply fun args)))))
 
 (defconst bytecomp-tests--byte-op-error-cases
   '(((car a) (wrong-type-argument listp a))
@@ -2143,7 +2137,7 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode 
python-mode)) \
                               `(lambda ,formals (,fun-sym ,@formals)))))))
                    (error-frame (bytecomp-tests--error-frame fun actuals)))
               (should (consp error-frame))
-              (should (equal (car error-frame) (list 'error expected-error)))
+              (should (equal (car error-frame) expected-error))
               (let ((frame (cdr error-frame)))
                 (should (equal (type-of frame) 'backtrace-frame))
                 (should (equal (cons (backtrace-frame-fun frame)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]