Add tests for several byte-compiler warnings

* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp/warn-autoload-not-on-top-level\.el)
(bytecomp/warn-callargs\.el)
(bytecomp/warn-defcustom-nogroup\.el)
(bytecomp/warn-defcustom-notype\.el)
(bytecomp/warn-defvar-lacks-prefix\.el)
(bytecomp/warn-format\.el)
(bytecomp/warn-lambda-malformed-interactive-spec\.el)
(bytecomp/warn-make-variable-buffer-local\.el)
(bytecomp/warn-redefine-defun-as-macro\.el)
(bytecomp/warn-redefine-defun\.el)
(bytecomp/warn-redefine-macro-as-defun\.el)
(bytecomp/warn-save-excursion\.el)
(bytecomp/warn-variable-let-bind-constant\.el)
(bytecomp/warn-variable-let-bind-nonvariable\.el)
(bytecomp/warn-variable-set-constant\.el)
(bytecomp/warn-variable-set-nonvariable\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-autoload-not-on-top-level.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-callargs.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-defcustom-nogroup.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-defcustom-notype.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-defvar-lacks-prefix.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-format.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-lambda-malformed-interactive-spec.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-make-variable-buffer-local.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-redefine-defun-as-macro.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-redefine-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-redefine-macro-as-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-save-excursion.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-let-bind-constant.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-let-bind-nonvariable.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-set-constant.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-set-nonvariable.el:
* test/lisp/emacs-lisp/bytecomp-tests.el: New files.
This commit is contained in:
Stefan Kangas 2020-12-03 17:08:28 +01:00
parent 805d82197f
commit 55300e6cdc
17 changed files with 102 additions and 2 deletions

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(autoload 'bar "baz" nil nil 'macro))

View file

@ -0,0 +1,5 @@
;;; -*- lexical-binding: t -*-
(defun foo (_x)
nil)
(defun bar ()
(foo 1 2))

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defcustom foo nil
:type 'boolean)

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defcustom foo nil
:group 'emacs)

View file

@ -0,0 +1,2 @@
;;; -*- lexical-binding: t -*-
(defvar foo nil)

View file

@ -0,0 +1,2 @@
;;; -*- lexical-binding: t -*-
(message "%s" 1 2)

View file

@ -0,0 +1,4 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(interactive "foo" "bar")
nil)

View file

@ -0,0 +1,4 @@
;;; -*- lexical-binding: t -*-
(defvar foobar)
(defun foo ()
(make-variable-buffer-local 'foobar))

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo () nil)
(defmacro foo () t)

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo () nil)
(defun foo () t)

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defmacro foo () t)
(defun foo () nil)

View file

@ -0,0 +1,5 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(save-excursion
(set-buffer (current-buffer))
nil))

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(let ((t 1)) t))

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(let (('t 1)) t))

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(setq t nil))

View file

@ -0,0 +1,3 @@
;;; -*- lexical-binding: t -*-
(defun foo ()
(set '(a) nil))

View file

@ -567,12 +567,39 @@ Subtests signal errors if something goes wrong."
(bytecomp--define-warning-file-test "error-lexical-var-with-symbol-value.el"
"symbol-value.*lexical var")
(bytecomp--define-warning-file-test "warn-autoload-not-on-top-level.el"
"compiler ignores.*autoload.*")
(bytecomp--define-warning-file-test "warn-callargs.el"
"with 2 arguments, but accepts only 1")
(bytecomp--define-warning-file-test "warn-defcustom-nogroup.el"
"fails to specify containing group")
(bytecomp--define-warning-file-test "warn-defcustom-notype.el"
"fails to specify type")
(bytecomp--define-warning-file-test "warn-defvar-lacks-prefix.el"
"var.*foo.*lacks a prefix")
(bytecomp--define-warning-file-test "warn-format.el"
"called with 2 args to fill 1 format field")
(bytecomp--define-warning-file-test "warn-free-setq.el"
"free.*foo")
(bytecomp--define-warning-file-test "warn-free-variable-reference.el"
"free.*bar")
(bytecomp--define-warning-file-test "warn-make-variable-buffer-local.el"
"make-variable-buffer-local.*not called at toplevel")
(bytecomp--define-warning-file-test "warn-interactive-only.el"
"next-line.*interactive use only.*forward-line")
(bytecomp--define-warning-file-test "warn-lambda-malformed-interactive-spec.el"
"malformed interactive spec")
(bytecomp--define-warning-file-test "warn-obsolete-defun.el"
"foo-obsolete.*obsolete function.*99.99")
@ -588,8 +615,29 @@ Subtests signal errors if something goes wrong."
(bytecomp--define-warning-file-test "warn-obsolete-variable.el"
"bytecomp--tests-obs.*obsolete.*99.99")
(bytecomp--define-warning-file-test "warn-interactive-only.el"
"next-line.*interactive use only.*forward-line")
(bytecomp--define-warning-file-test "warn-redefine-defun-as-macro.el"
"as both function and macro")
(bytecomp--define-warning-file-test "warn-redefine-macro-as-defun.el"
"as both function and macro")
(bytecomp--define-warning-file-test "warn-redefine-defun.el"
"defined multiple")
(bytecomp--define-warning-file-test "warn-save-excursion.el"
"with-current.*rather than save-excursion")
(bytecomp--define-warning-file-test "warn-variable-let-bind-constant.el"
"let-bind constant")
(bytecomp--define-warning-file-test "warn-variable-let-bind-nonvariable.el"
"let-bind nonvariable")
(bytecomp--define-warning-file-test "warn-variable-set-constant.el"
"variable reference to constant")
(bytecomp--define-warning-file-test "warn-variable-set-nonvariable.el"
"variable reference to nonvariable")
;;;; Macro expansion.