aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/keymap-tests.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index b7715a280a6..aa710519825 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -226,6 +226,7 @@ commit 86c19714b097aa477d339ed99ffb5136c755a046."
226 226
227(defun keymap-tests--command-1 () (interactive) nil) 227(defun keymap-tests--command-1 () (interactive) nil)
228(defun keymap-tests--command-2 () (interactive) nil) 228(defun keymap-tests--command-2 () (interactive) nil)
229(defun keymap-tests--command-3 () (interactive) nil)
229(put 'keymap-tests--command-1 :advertised-binding [?y]) 230(put 'keymap-tests--command-1 :advertised-binding [?y])
230 231
231(ert-deftest keymap-where-is-internal () 232(ert-deftest keymap-where-is-internal ()
@@ -430,6 +431,38 @@ g .. h foo
430 (make-non-key-event 'keymap-tests-event) 431 (make-non-key-event 'keymap-tests-event)
431 (should (equal (where-is-internal 'keymap-tests-command) '([3 103])))) 432 (should (equal (where-is-internal 'keymap-tests-command) '([3 103]))))
432 433
434(ert-deftest keymap-set-consistency ()
435 (let ((k (make-sparse-keymap)))
436 ;; `keymap-set' returns the binding, `keymap-set-after' doesn't,
437 ;; so we need to check for nil. <sigh>
438 (should (keymap-set k "a" "a"))
439 (should (equal (keymap-lookup k "a") (key-parse "a")))
440 (should-not (keymap-set-after k "b" "b"))
441 (should (equal (keymap-lookup k "b") (key-parse "b")))
442 (should-not (keymap-set-after k "d" "d" t))
443 (should (equal (keymap-lookup k "d") (key-parse "d")))
444 (should-not (keymap-set-after k "e" "e" nil))
445 (should (equal (keymap-lookup k "e") (key-parse "e")))
446 ;; This doesn't fail, but it does not add the 'f' binding after 'a'
447 (should-not (keymap-set-after k "f" "f" "a"))
448 (should (equal (keymap-lookup k "f") (key-parse "f")))))
449
450(ert-deftest keymap-set-after-menus ()
451 (let ((map (make-sparse-keymap)))
452 (keymap-set map "<cmd1>"
453 '(menu-item "Run Command 1" keymap-tests--command-1
454 :help "Command 1 Help"))
455 (keymap-set-after map "<cmd2>"
456 '(menu-item "Run Command 2" keymap-tests--command-2
457 :help "Command 2 Help"))
458 (keymap-set-after map "<cmd3>"
459 '(menu-item "Run Command 3" keymap-tests--command-3
460 :help "Command 3 Help")
461 'cmd1)
462 (should (equal (caadr map) 'cmd1))
463 (should (equal (caaddr map) 'cmd3))
464 (should (equal (caar (last map)) 'cmd2))))
465
433(ert-deftest keymap-test-duplicate-definitions () 466(ert-deftest keymap-test-duplicate-definitions ()
434 "Check that defvar-keymap rejects duplicate key definitions." 467 "Check that defvar-keymap rejects duplicate key definitions."
435 (should-error 468 (should-error