aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Kangas2020-11-07 07:55:50 +0100
committerStefan Kangas2020-11-07 07:55:50 +0100
commit6df06148e55959c0a31c50e260cfb697de3b4394 (patch)
treec8788e9ece50e9298ae11039a6488ead69b5e3d8 /test/src
parentb7b9bbb93d669f08fd485cb93bcd4caf7ad13613 (diff)
downloademacs-6df06148e55959c0a31c50e260cfb697de3b4394.tar.gz
emacs-6df06148e55959c0a31c50e260cfb697de3b4394.zip
Add some more tests for keymap.c
* test/src/keymap-tests.el (keymap-make-keymap) (keymap-make-sparse-keymap, keymap-keymapp) (keymap-keymap-parent, keymap-keymap-set-parent/returns-parent) (keymap-copy-keymap/is-equal, keymap-copy-keymap/is-not-eq) (keymap-lookup-key, keymap-apropos-internal) (keymap-apropos-internal/predicate): New tests. (keymap-tests--make-keymap-test): New defun.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/keymap-tests.el49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index 0f3fde48042..8331a41e3f8 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -24,6 +24,45 @@
24 24
25(require 'ert) 25(require 'ert)
26 26
27(defun keymap-tests--make-keymap-test (fun)
28 (should (eq (car (funcall fun)) 'keymap))
29 (should (proper-list-p (funcall fun)))
30 (should (equal (car (last (funcall fun "foo"))) "foo")))
31
32(ert-deftest keymap-make-keymap ()
33 (keymap-tests--make-keymap-test #'make-keymap)
34 (should (char-table-p (cadr (make-keymap)))))
35
36(ert-deftest keymap-make-sparse-keymap ()
37 (keymap-tests--make-keymap-test #'make-sparse-keymap))
38
39(ert-deftest keymap-keymapp ()
40 (should (keymapp (make-keymap)))
41 (should (keymapp (make-sparse-keymap)))
42 (should-not (keymapp '(foo bar))))
43
44(ert-deftest keymap-keymap-parent ()
45 (should-not (keymap-parent (make-keymap)))
46 (should-not (keymap-parent (make-sparse-keymap)))
47 (let ((map (make-keymap)))
48 (set-keymap-parent map help-mode-map)
49 (should (equal (keymap-parent map) help-mode-map))))
50
51(ert-deftest keymap-keymap-set-parent/returns-parent ()
52 (let ((map (make-keymap)))
53 (should (equal (set-keymap-parent map help-mode-map) help-mode-map))))
54
55(ert-deftest keymap-copy-keymap/is-equal ()
56 (should (equal (copy-keymap help-mode-map) help-mode-map)))
57
58(ert-deftest keymap-copy-keymap/is-not-eq ()
59 (should-not (eq (copy-keymap help-mode-map) help-mode-map)))
60
61(ert-deftest keymap-lookup-key ()
62 (let ((map (make-keymap)))
63 (define-key map [?a] 'foo)
64 (should (eq (lookup-key map [?a]) 'foo))))
65
27(ert-deftest describe-buffer-bindings/header-in-current-buffer () 66(ert-deftest describe-buffer-bindings/header-in-current-buffer ()
28 "Header should be inserted into the current buffer. 67 "Header should be inserted into the current buffer.
29https://debbugs.gnu.org/39149#31" 68https://debbugs.gnu.org/39149#31"
@@ -135,6 +174,16 @@ commit 86c19714b097aa477d339ed99ffb5136c755a046."
135 (where-is-internal 'execute-extended-command global-map t)) 174 (where-is-internal 'execute-extended-command global-map t))
136 [#x8000078]))) 175 [#x8000078])))
137 176
177(ert-deftest keymap-apropos-internal ()
178 (should (equal (apropos-internal "^next-line$") '(next-line)))
179 (should (>= (length (apropos-internal "^help")) 100))
180 (should-not (apropos-internal "^test-a-missing-symbol-foo-bar-zut$")))
181
182(ert-deftest keymap-apropos-internal/predicate ()
183 (should (equal (apropos-internal "^next-line$" #'commandp) '(next-line)))
184 (should (>= (length (apropos-internal "^help" #'commandp)) 15))
185 (should-not (apropos-internal "^next-line$" #'keymapp)))
186
138(provide 'keymap-tests) 187(provide 'keymap-tests)
139 188
140;;; keymap-tests.el ends here 189;;; keymap-tests.el ends here