diff options
| author | Andrea Corallo | 2019-06-23 12:08:59 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:33:44 +0100 |
| commit | 3f96f72b59a627944040228984ec48cf0f74ecec (patch) | |
| tree | e291a92d2a9bd5f64bcecefc43ae5f030324e187 /test/src | |
| parent | 39390edcf95f3fe21dbb68e0e35f1d8b5b93588e (diff) | |
| download | emacs-3f96f72b59a627944040228984ec48cf0f74ecec.tar.gz emacs-3f96f72b59a627944040228984ec48cf0f74ecec.zip | |
add non locals tests
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/comp-tests.el | 55 |
1 files changed, 55 insertions, 0 deletions
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 @@ | |||
| 345 | (buffer-string)) | 345 | (buffer-string)) |
| 346 | "abcd"))) | 346 | "abcd"))) |
| 347 | 347 | ||
| 348 | (ert-deftest comp-tests-non-locals () | ||
| 349 | "Test non locals." | ||
| 350 | (defun comp-tests-err-arith-f () | ||
| 351 | (/ 1 0)) | ||
| 352 | (defun comp-tests-err-foo-f () | ||
| 353 | (error "foo")) | ||
| 354 | |||
| 355 | (defun comp-tests-condition-case-0-f () | ||
| 356 | ;; Bpushhandler Bpophandler | ||
| 357 | (condition-case | ||
| 358 | err | ||
| 359 | (comp-tests-err-arith-f) | ||
| 360 | (arith-error (concat "arith-error " | ||
| 361 | (error-message-string err) | ||
| 362 | " catched")) | ||
| 363 | (error (concat "error " | ||
| 364 | (error-message-string err) | ||
| 365 | " catched")))) | ||
| 366 | |||
| 367 | (defun comp-tests-condition-case-1-f () | ||
| 368 | ;; Bpushhandler Bpophandler | ||
| 369 | (condition-case | ||
| 370 | err | ||
| 371 | (comp-tests-err-foo-f) | ||
| 372 | (arith-error (concat "arith-error " | ||
| 373 | (error-message-string err) | ||
| 374 | " catched")) | ||
| 375 | (error (concat "error " | ||
| 376 | (error-message-string err) | ||
| 377 | " catched")))) | ||
| 378 | |||
| 379 | (defun comp-tests-catch-f (f) | ||
| 380 | (catch 'foo | ||
| 381 | (funcall f))) | ||
| 382 | |||
| 383 | (defun comp-tests-throw-f (x) | ||
| 384 | (throw 'foo x)) | ||
| 385 | |||
| 386 | (byte-compile #'comp-tests-condition-case-0-f) | ||
| 387 | (native-compile #'comp-tests-condition-case-0-f) | ||
| 388 | (byte-compile #'comp-tests-condition-case-1-f) | ||
| 389 | (native-compile #'comp-tests-condition-case-1-f) | ||
| 390 | (byte-compile #'comp-tests-catch-f) | ||
| 391 | (native-compile #'comp-tests-catch-f) | ||
| 392 | (byte-compile #'comp-tests-throw-f) | ||
| 393 | (native-compile #'comp-tests-throw-f) | ||
| 394 | |||
| 395 | (should (string= (comp-tests-condition-case-0-f) | ||
| 396 | "arith-error Arithmetic error catched")) | ||
| 397 | (should (string= (comp-tests-condition-case-1-f) | ||
| 398 | "error foo catched")) | ||
| 399 | (should (= (comp-tests-catch-f (lambda () (throw 'foo 3))) 3)) | ||
| 400 | (should (= (catch 'foo | ||
| 401 | (comp-tests-throw-f 3))))) | ||
| 402 | |||
| 348 | (ert-deftest comp-tests-gc () | 403 | (ert-deftest comp-tests-gc () |
| 349 | "Try to do some longer computation to let the gc kick in." | 404 | "Try to do some longer computation to let the gc kick in." |
| 350 | (dotimes (_ 100000) | 405 | (dotimes (_ 100000) |