diff options
| author | Stefan Kangas | 2020-11-22 07:19:11 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2020-11-22 07:19:11 +0100 |
| commit | 9490f12c4dc4deb16f4e900646319f6de033982c (patch) | |
| tree | e6d5264ae011226fa458406702c0a39aeb4d8fa4 | |
| parent | b6339fc19c378d66ce1bc53499552dfaa3c0c8c0 (diff) | |
| download | emacs-9490f12c4dc4deb16f4e900646319f6de033982c.tar.gz emacs-9490f12c4dc4deb16f4e900646319f6de033982c.zip | |
Test for byte-compiler warning "variable lacks prefix"
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp--with-warning-test): New macro.
(bytecomp-warn-wrong-args, bytecomp-warn-wrong-args-subr):
Use above new macro.
(bytecomp-warn-variable-lacks-prefix): New test.
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index e0a3cc2fb82..680aa514a27 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -516,19 +516,25 @@ Subtests signal errors if something goes wrong." | |||
| 516 | ;; Should not warn that mt--test2 is not known to be defined. | 516 | ;; Should not warn that mt--test2 is not known to be defined. |
| 517 | (should-not (re-search-forward "my--test2" nil t)))) | 517 | (should-not (re-search-forward "my--test2" nil t)))) |
| 518 | 518 | ||
| 519 | (defmacro bytecomp--with-warning-test (re-warning &rest form) | ||
| 520 | (declare (indent 1)) | ||
| 521 | `(with-current-buffer (get-buffer-create "*Compile-Log*") | ||
| 522 | (let ((inhibit-read-only t)) (erase-buffer)) | ||
| 523 | (byte-compile ,@form) | ||
| 524 | (ert-info ((buffer-string) :prefix "buffer: ") | ||
| 525 | (should (re-search-forward ,re-warning))))) | ||
| 526 | |||
| 519 | (ert-deftest bytecomp-warn-wrong-args () | 527 | (ert-deftest bytecomp-warn-wrong-args () |
| 520 | (with-current-buffer (get-buffer-create "*Compile-Log*") | 528 | (bytecomp--with-warning-test "remq.*3.*2" |
| 521 | (let ((inhibit-read-only t)) (erase-buffer)) | 529 | '(remq 1 2 3))) |
| 522 | (byte-compile '(remq 1 2 3)) | ||
| 523 | (ert-info ((buffer-string) :prefix "buffer: ") | ||
| 524 | (should (re-search-forward "remq.*3.*2"))))) | ||
| 525 | 530 | ||
| 526 | (ert-deftest bytecomp-warn-wrong-args-subr () | 531 | (ert-deftest bytecomp-warn-wrong-args-subr () |
| 527 | (with-current-buffer (get-buffer-create "*Compile-Log*") | 532 | (bytecomp--with-warning-test "safe-length.*3.*1" |
| 528 | (let ((inhibit-read-only t)) (erase-buffer)) | 533 | '(safe-length 1 2 3))) |
| 529 | (byte-compile '(safe-length 1 2 3)) | 534 | |
| 530 | (ert-info ((buffer-string) :prefix "buffer: ") | 535 | (ert-deftest bytecomp-warn-variable-lacks-prefix () |
| 531 | (should (re-search-forward "safe-length.*3.*1"))))) | 536 | (bytecomp--with-warning-test "foo.*lacks a prefix" |
| 537 | '(defvar foo nil))) | ||
| 532 | 538 | ||
| 533 | (ert-deftest test-eager-load-macro-expansion () | 539 | (ert-deftest test-eager-load-macro-expansion () |
| 534 | (test-byte-comp-compile-and-load nil | 540 | (test-byte-comp-compile-and-load nil |