From 841dcfa7c351118aef402e58c3a204b671e1fe13 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 9 Apr 2021 13:44:44 +0200 Subject: [PATCH] Use lexical-binding in loadhist.el and add tests * lisp/loadhist.el: Use lexical-binding. * test/lisp/loadhist-tests.el: New file. --- lisp/loadhist.el | 2 +- test/lisp/loadhist-tests.el | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/lisp/loadhist-tests.el diff --git a/lisp/loadhist.el b/lisp/loadhist.el index 59c002d3078..0b12bdad058 100644 --- a/lisp/loadhist.el +++ b/lisp/loadhist.el @@ -1,4 +1,4 @@ -;;; loadhist.el --- lisp functions for working with feature groups +;;; loadhist.el --- lisp functions for working with feature groups -*- lexical-binding: t -*- ;; Copyright (C) 1995, 1998, 2000-2021 Free Software Foundation, Inc. diff --git a/test/lisp/loadhist-tests.el b/test/lisp/loadhist-tests.el new file mode 100644 index 00000000000..b29796da42d --- /dev/null +++ b/test/lisp/loadhist-tests.el @@ -0,0 +1,57 @@ +;;; loadhist-tests.el --- Tests for loadhist.el -*- lexical-binding:t -*- + +;; Copyright (C) 2021 Free Software Foundation, Inc. + +;; Author: Stefan Kangas + +;; 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 . + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'loadhist) + +(ert-deftest loadhist-tests-feature-symbols () + (should (equal (file-name-base (car (feature-symbols 'loadhist))) "loadhist")) + (should-not (feature-symbols 'non-existent-feature))) + +(ert-deftest loadhist-tests-feature-file () + (should (equal (file-name-base (feature-file 'loadhist)) "loadhist")) + (should-error (feature-file 'non-existent-feature))) + +(ert-deftest loadhist-tests-file-loadhist-lookup () + ;; This should probably be extended... + (should (listp (file-loadhist-lookup "loadhist")))) + +(ert-deftest loadhist-tests-file-provides () + (should (eq (car (file-provides "loadhist")) 'loadhist))) + +(ert-deftest loadhist-tests-file-requires () + (should-not (file-requires "loadhist"))) + +(ert-deftest loadhist-tests-file-dependents () + (require 'dired-x) + (let ((deps (file-dependents "dired"))) + (should (member "dired-x" (mapcar #'file-name-base deps))))) + +(ert-deftest loadhist-tests-unload-feature () + (require 'dired-x) + (should-error (unload-feature 'dired)) + (unload-feature 'dired-x)) + +;;; loadhist-tests.el ends here -- 2.39.5