]> git.eshelyaron.com Git - emacs.git/commitdiff
Make describe-keymap tests more robust
authorStefan Kangas <stefankangas@gmail.com>
Tue, 8 Aug 2023 01:45:19 +0000 (03:45 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Tue, 8 Aug 2023 01:54:02 +0000 (03:54 +0200)
* test/lisp/help-fns-tests.el
(help-fns-test-describe-keymap/symbol)
(help-fns-test-describe-keymap/value)
(help-fns-test-describe-keymap/not-keymap)
(help-fns-test-describe-keymap/let-bound)
(help-fns-test-describe-keymap/dynamically-bound-no-file): Make
tests independent of minibuffer-local-must-match-map.

test/lisp/help-fns-tests.el

index 243a45ae6d26c0fd719061f20cc763589cc148c6..56c521e765e728048b2df9e4fa96901baf977ec0 100644 (file)
@@ -132,6 +132,12 @@ Return first line of the output of (describe-function-1 FUNC)."
 
 \f
 ;;; Tests for describe-keymap
+
+(defvar-keymap help-fns-test-map
+  "a" 'test-cmd-a
+  "b" 'test-cmd-b
+  "c" 'test-cmd-c)
+
 (ert-deftest help-fns-test-find-keymap-name ()
   (should (equal (help-fns-find-keymap-name lisp-mode-map) 'lisp-mode-map))
   ;; Follow aliasing.
@@ -142,27 +148,32 @@ Return first line of the output of (describe-function-1 FUNC)."
     (makunbound 'foo-test-map)))
 
 (ert-deftest help-fns-test-describe-keymap/symbol ()
-  (describe-keymap 'minibuffer-local-must-match-map)
+  (describe-keymap 'help-fns-test-map)
   (with-current-buffer "*Help*"
-    (should (looking-at "^minibuffer-local-must-match-map is"))))
+    (should (looking-at "^help-fns-test-map is"))
+    (should (re-search-forward (rx word-start "a" word-end
+                                   (+ blank)
+                                   word-start "test-cmd-a" word-end)
+                               nil t))))
 
 (ert-deftest help-fns-test-describe-keymap/value ()
-  (describe-keymap minibuffer-local-must-match-map)
+  (describe-keymap help-fns-test-map)
   (with-current-buffer "*Help*"
     (should (looking-at "\nKey"))))
 
 (ert-deftest help-fns-test-describe-keymap/not-keymap ()
   (should-error (describe-keymap nil))
-  (should-error (describe-keymap emacs-version)))
+  (should-error (describe-keymap emacs-version))
+  (should-error (describe-keymap 'some-undefined-variable-foobar)))
 
 (ert-deftest help-fns-test-describe-keymap/let-bound ()
-  (let ((foobar minibuffer-local-must-match-map))
+  (let ((foobar help-fns-test-map))
     (describe-keymap foobar)
     (with-current-buffer "*Help*"
       (should (looking-at "\nKey")))))
 
 (ert-deftest help-fns-test-describe-keymap/dynamically-bound-no-file ()
-  (setq help-fns-test--describe-keymap-foo minibuffer-local-must-match-map)
+  (setq help-fns-test--describe-keymap-foo help-fns-test-map)
   (describe-keymap 'help-fns-test--describe-keymap-foo)
   (with-current-buffer "*Help*"
     (should (looking-at "^help-fns-test--describe-keymap-foo is"))))