diff options
Diffstat (limited to 'test/lisp/kmacro-tests.el')
-rw-r--r-- | test/lisp/kmacro-tests.el | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el index e1eabeb9591..75d700070aa 100644 --- a/test/lisp/kmacro-tests.el +++ b/test/lisp/kmacro-tests.el @@ -91,33 +91,30 @@ body in KEYS-AND-BODY." ,docstring ,@keys (kmacro-tests-with-kmacro-clean-slate ,@body)))) -(defvar kmacro-tests-keymap - (let ((map (make-sparse-keymap))) - (dotimes (i 26) - (define-key map (string (+ ?a i)) 'self-insert-command)) - (dotimes (i 10) - (define-key map (string (+ ?0 i)) 'self-insert-command)) - ;; Define a few key sequences of different lengths. - (dolist (item '(("\C-a" . beginning-of-line) - ("\C-b" . backward-char) - ("\C-e" . end-of-line) - ("\C-f" . forward-char) - ("\C-r" . isearch-backward) - ("\C-u" . universal-argument) - ("\C-w" . kill-region) - ("\C-SPC" . set-mark-command) - ("\M-w" . kill-ring-save) - ("\M-x" . execute-extended-command) - ("\C-cd" . downcase-word) - ("\C-cxu" . upcase-word) - ("\C-cxq" . quoted-insert) - ("\C-cxi" . kmacro-insert-counter) - ("\C-x\C-k" . kmacro-keymap))) - (define-key map (car item) (cdr item))) - map) - "Keymap to use for testing keyboard macros. +(defvar-keymap kmacro-tests-keymap + :doc "Keymap to use for testing keyboard macros. This is used to obtain consistent results even if tests are run -in an environment with rebound keys.") +in an environment with rebound keys." + ;; Define a few key sequences of different lengths. + "C-a" 'beginning-of-line + "C-b" 'backward-char + "C-e" 'end-of-line + "C-f" 'forward-char + "C-r" 'isearch-backward + "C-u" 'universal-argument + "C-w" 'kill-region + "C-SPC" 'set-mark-command + "M-w" 'kill-ring-save + "M-x" 'execute-extended-command + "C-c d" 'downcase-word + "C-c x u" 'upcase-word + "C-c x q" 'quoted-insert + "C-c x i" 'kmacro-insert-counter + "C-x C-k" 'kmacro-keymap) +(dotimes (i 26) + (keymap-set kmacro-tests-keymap (string (+ ?a i)) 'self-insert-command)) +(dotimes (i 10) + (keymap-set kmacro-tests-keymap (string (+ ?0 i)) 'self-insert-command)) (defvar kmacro-tests-events nil "Input events used by the kmacro test in progress.") @@ -583,8 +580,10 @@ This is a regression test for: Bug#3412, Bug#11817." ;; Check the bound key and run it and verify correct counter ;; and format. (should (equal (string-to-vector "\C-cxi") - (car (kmacro-extract-lambda - (key-binding "\C-x\C-kA"))))) + (car (with-suppressed-warnings + ((obsolete kmacro-extract-lambda)) + (kmacro-extract-lambda + (key-binding "\C-x\C-kA")))))) (kmacro-tests-should-insert "<5>" (funcall (key-binding "\C-x\C-kA"))))) @@ -608,7 +607,7 @@ This is a regression test for: Bug#3412, Bug#11817." (dotimes (i 2) (kmacro-tests-define-macro (make-vector (1+ i) (+ ?a i))) (kmacro-name-last-macro 'kmacro-tests-symbol-for-test) - (should (fboundp 'kmacro-tests-symbol-for-test))) + (should (commandp 'kmacro-tests-symbol-for-test))) ;; Now run the function bound to the symbol. Result should be the ;; second macro. @@ -825,6 +824,15 @@ This is a regression for item 7 in Bug#24991." :macro-result "x") (kmacro-tests-simulate-command '(beginning-of-line)))) +(ert-deftest kmacro-tests--cl-print () + (should (equal (cl-prin1-to-string + (kmacro [?a ?b backspace backspace])) + "#f(kmacro \"a b <backspace> <backspace>\")")) + (should (equal (cl-prin1-to-string + (with-suppressed-warnings ((obsolete kmacro-lambda-form)) + (kmacro-lambda-form [?a ?b backspace backspace] 1 "%d"))) + "#f(kmacro \"a b <backspace> <backspace>\" 1 \"%d\")"))) + (cl-defun kmacro-tests-run-step-edit (macro &key events sequences result macro-result) "Set up and run a test of `kmacro-step-edit-macro'. |