From: Andrea Corallo Date: Sun, 23 Jun 2019 10:08:59 +0000 (+0200) Subject: add non locals tests X-Git-Tag: emacs-28.0.90~2727^2~1454 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3f96f72b59a627944040228984ec48cf0f74ecec;p=emacs.git add non locals tests --- diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 6a643df9d3e..6a7370a880c 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -345,6 +345,61 @@ (buffer-string)) "abcd"))) +(ert-deftest comp-tests-non-locals () + "Test non locals." + (defun comp-tests-err-arith-f () + (/ 1 0)) + (defun comp-tests-err-foo-f () + (error "foo")) + + (defun comp-tests-condition-case-0-f () + ;; Bpushhandler Bpophandler + (condition-case + err + (comp-tests-err-arith-f) + (arith-error (concat "arith-error " + (error-message-string err) + " catched")) + (error (concat "error " + (error-message-string err) + " catched")))) + + (defun comp-tests-condition-case-1-f () + ;; Bpushhandler Bpophandler + (condition-case + err + (comp-tests-err-foo-f) + (arith-error (concat "arith-error " + (error-message-string err) + " catched")) + (error (concat "error " + (error-message-string err) + " catched")))) + + (defun comp-tests-catch-f (f) + (catch 'foo + (funcall f))) + + (defun comp-tests-throw-f (x) + (throw 'foo x)) + + (byte-compile #'comp-tests-condition-case-0-f) + (native-compile #'comp-tests-condition-case-0-f) + (byte-compile #'comp-tests-condition-case-1-f) + (native-compile #'comp-tests-condition-case-1-f) + (byte-compile #'comp-tests-catch-f) + (native-compile #'comp-tests-catch-f) + (byte-compile #'comp-tests-throw-f) + (native-compile #'comp-tests-throw-f) + + (should (string= (comp-tests-condition-case-0-f) + "arith-error Arithmetic error catched")) + (should (string= (comp-tests-condition-case-1-f) + "error foo catched")) + (should (= (comp-tests-catch-f (lambda () (throw 'foo 3))) 3)) + (should (= (catch 'foo + (comp-tests-throw-f 3))))) + (ert-deftest comp-tests-gc () "Try to do some longer computation to let the gc kick in." (dotimes (_ 100000)