mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-11 00:30:17 -08:00
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.
This commit is contained in:
parent
b6339fc19c
commit
9490f12c4d
1 changed files with 16 additions and 10 deletions
|
|
@ -516,19 +516,25 @@ Subtests signal errors if something goes wrong."
|
||||||
;; Should not warn that mt--test2 is not known to be defined.
|
;; Should not warn that mt--test2 is not known to be defined.
|
||||||
(should-not (re-search-forward "my--test2" nil t))))
|
(should-not (re-search-forward "my--test2" nil t))))
|
||||||
|
|
||||||
(ert-deftest bytecomp-warn-wrong-args ()
|
(defmacro bytecomp--with-warning-test (re-warning &rest form)
|
||||||
(with-current-buffer (get-buffer-create "*Compile-Log*")
|
(declare (indent 1))
|
||||||
|
`(with-current-buffer (get-buffer-create "*Compile-Log*")
|
||||||
(let ((inhibit-read-only t)) (erase-buffer))
|
(let ((inhibit-read-only t)) (erase-buffer))
|
||||||
(byte-compile '(remq 1 2 3))
|
(byte-compile ,@form)
|
||||||
(ert-info ((buffer-string) :prefix "buffer: ")
|
(ert-info ((buffer-string) :prefix "buffer: ")
|
||||||
(should (re-search-forward "remq.*3.*2")))))
|
(should (re-search-forward ,re-warning)))))
|
||||||
|
|
||||||
|
(ert-deftest bytecomp-warn-wrong-args ()
|
||||||
|
(bytecomp--with-warning-test "remq.*3.*2"
|
||||||
|
'(remq 1 2 3)))
|
||||||
|
|
||||||
(ert-deftest bytecomp-warn-wrong-args-subr ()
|
(ert-deftest bytecomp-warn-wrong-args-subr ()
|
||||||
(with-current-buffer (get-buffer-create "*Compile-Log*")
|
(bytecomp--with-warning-test "safe-length.*3.*1"
|
||||||
(let ((inhibit-read-only t)) (erase-buffer))
|
'(safe-length 1 2 3)))
|
||||||
(byte-compile '(safe-length 1 2 3))
|
|
||||||
(ert-info ((buffer-string) :prefix "buffer: ")
|
(ert-deftest bytecomp-warn-variable-lacks-prefix ()
|
||||||
(should (re-search-forward "safe-length.*3.*1")))))
|
(bytecomp--with-warning-test "foo.*lacks a prefix"
|
||||||
|
'(defvar foo nil)))
|
||||||
|
|
||||||
(ert-deftest test-eager-load-macro-expansion ()
|
(ert-deftest test-eager-load-macro-expansion ()
|
||||||
(test-byte-comp-compile-and-load nil
|
(test-byte-comp-compile-and-load nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue