diff options
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-resources/bc-test-alpha.el | 9 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-resources/bc-test-beta.el | 6 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 18 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/copyright-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/shortdoc-tests.el | 45 |
5 files changed, 82 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/bc-test-alpha.el b/test/lisp/emacs-lisp/bytecomp-resources/bc-test-alpha.el new file mode 100644 index 00000000000..6997d91b26a --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/bc-test-alpha.el @@ -0,0 +1,9 @@ +;;; -*- lexical-binding: t -*- + +(require 'bc-test-beta) + +(defun bc-test-alpha-f (x) + (let ((y nil)) + (list y (bc-test-beta-f x)))) + +(provide 'bc-test-alpha) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/bc-test-beta.el b/test/lisp/emacs-lisp/bytecomp-resources/bc-test-beta.el new file mode 100644 index 00000000000..9205a13d7d5 --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/bc-test-beta.el @@ -0,0 +1,6 @@ +;;; -*- lexical-binding: t -*- + +(defsubst bc-test-beta-f (y) + y) + +(provide 'bc-test-beta) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index c9ab3ec1f1b..33413f5a002 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -1312,6 +1312,24 @@ compiled correctly." (funcall f 3)) 4))) +(declare-function bc-test-alpha-f (ert-resource-file "bc-test-alpha.el")) + +(ert-deftest bytecomp-defsubst () + ;; Check that lexical variables don't leak into inlined code. See + ;; https://lists.gnu.org/archive/html/emacs-devel/2021-05/msg01227.html + + ;; First, remove any trace of the functions and package defined: + (fmakunbound 'bc-test-alpha-f) + (fmakunbound 'bc-test-beta-f) + (setq features (delq 'bc-test-beta features)) + ;; Byte-compile one file that uses a function from another file that isn't + ;; compiled. + (let ((file (ert-resource-file "bc-test-alpha.el")) + (load-path (cons (ert-resource-directory) load-path))) + (byte-compile-file file) + (load-file (concat file "c")) + (should (equal (bc-test-alpha-f 'a) '(nil a))))) + ;; Local Variables: ;; no-byte-compile: t ;; End: diff --git a/test/lisp/emacs-lisp/copyright-tests.el b/test/lisp/emacs-lisp/copyright-tests.el index 7deb8b53a2e..6bb6e350d17 100644 --- a/test/lisp/emacs-lisp/copyright-tests.el +++ b/test/lisp/emacs-lisp/copyright-tests.el @@ -37,8 +37,12 @@ . ";; Copyright (C) 2017, 2019 Free Software Foundation, Inc.") (";; Copyright (C) 2017-2018 Free Software Foundation, Inc." . ";; Copyright (C) 2017-2019 Free Software Foundation, Inc.") + (";; Copyright (C) 2017–2018 Free Software Foundation, Inc." + . ";; Copyright (C) 2017–2019 Free Software Foundation, Inc.") (";; Copyright (C) 2005-2006, 2015, 2017-2018 Free Software Foundation, Inc." . ";; Copyright (C) 2005-2006, 2015, 2017-2019 Free Software Foundation, Inc.") + (";; Copyright (C) 2005–2006, 2015, 2017–2018 Free Software Foundation, Inc." + . ";; Copyright (C) 2005–2006, 2015, 2017–2019 Free Software Foundation, Inc.") (";; copyright '18 FSF" . ";; copyright '18, '19 FSF"))) diff --git a/test/lisp/emacs-lisp/shortdoc-tests.el b/test/lisp/emacs-lisp/shortdoc-tests.el new file mode 100644 index 00000000000..050aac31659 --- /dev/null +++ b/test/lisp/emacs-lisp/shortdoc-tests.el @@ -0,0 +1,45 @@ +;;; shortdoc-tests.el --- tests for shortdoc.el -*- lexical-binding: t -*- + +;; Copyright (C) 2021 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. + +(require 'ert) +(require 'shortdoc) + +(defun shortdoc-tests--tree-contains (tree fun) + "Whether TREE contains a call to FUN." + (and (proper-list-p tree) + (or (eq (car tree) fun) + (cl-some (lambda (x) (shortdoc-tests--tree-contains x fun)) tree)))) + +(ert-deftest shortdoc-examples () + "Check that each example actually contains the corresponding form." + (dolist (group shortdoc--groups) + (dolist (item group) + (when (consp item) + (let ((fun (car item)) + (props (cdr item))) + (while props + (when (memq (car props) '(:eval :no-eval :no-eval*)) + (let* ((example (cadr props)) + (expr (cond + ((consp example) example) + ((stringp example) (read example))))) + (should (shortdoc-tests--tree-contains expr fun)))) + (setq props (cddr props)))))))) + +(provide 'shortdoc-tests) |