aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-08-18 18:06:33 +0300
committerEli Zaretskii2016-08-18 18:06:33 +0300
commitb305fab44c10488e601096d506a30259961e8d7f (patch)
tree550041ca86302f8f21f668087fd4a208bb3e8b44 /test/src
parent45522a1ed316ea639bee563e7ad91060b921dbfa (diff)
downloademacs-b305fab44c10488e601096d506a30259961e8d7f.tar.gz
emacs-b305fab44c10488e601096d506a30259961e8d7f.zip
Add tests for 'substitute-command-keys'
* test/src/doc-tests.el (doc-test-substitute-command-keys): New tests.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/doc-tests.el92
1 files changed, 92 insertions, 0 deletions
diff --git a/test/src/doc-tests.el b/test/src/doc-tests.el
new file mode 100644
index 00000000000..be490545747
--- /dev/null
+++ b/test/src/doc-tests.el
@@ -0,0 +1,92 @@
1;;; doc-tests.el --- Tests for doc.c
2
3;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5;; Author: Eli Zaretskii <eliz@gnu.org>
6
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; This program is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'ert)
23
24(ert-deftest doc-test-substitute-command-keys ()
25 ;; Bindings.
26 (should (string= (substitute-command-keys "foo \\[goto-char]") "foo M-g c"))
27 ;; Cannot use string= here, as that compares unibyte and multibyte
28 ;; strings not equal.
29 (should (compare-strings
30 (substitute-command-keys "\200 \\[goto-char]") nil nil
31 "\200 M-g c" nil nil))
32 ;; Literals.
33 (should (string= (substitute-command-keys "foo \\=\\[goto-char]")
34 "foo \\[goto-char]"))
35 (should (string= (substitute-command-keys "foo \\=\\=")
36 "foo \\="))
37 ;; Keymaps.
38 (should (string= (substitute-command-keys
39 "\\{minibuffer-local-must-match-map}")
40 "\
41key binding
42--- -------
43
44C-g abort-recursive-edit
45TAB minibuffer-complete
46C-j minibuffer-complete-and-exit
47RET minibuffer-complete-and-exit
48ESC Prefix Command
49SPC minibuffer-complete-word
50? minibuffer-completion-help
51<C-tab> file-cache-minibuffer-complete
52<XF86Back> previous-history-element
53<XF86Forward> next-history-element
54<down> next-line-or-history-element
55<next> next-history-element
56<prior> switch-to-completions
57<up> previous-line-or-history-element
58
59M-v switch-to-completions
60
61M-n next-history-element
62M-p previous-history-element
63M-r previous-matching-history-element
64M-s next-matching-history-element
65
66"))
67 (should (string=
68 (substitute-command-keys
69 "\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]")
70 "C-g"))
71 ;; Allow any style of quotes, since the terminal might not support
72 ;; UTF-8.
73 (should (string-match
74 "\nUses keymap [`‘']foobar-map['’], which is not currently defined.\n"
75 (substitute-command-keys "\\{foobar-map}")))
76 ;; Quotes.
77 (should (let ((text-quoting-style 'grave))
78 (string= (substitute-command-keys "quotes `like this'")
79 "quotes `like this'")))
80 (should (let ((text-quoting-style 'grave))
81 (string= (substitute-command-keys "quotes ‘like this’")
82 "quotes ‘like this’")))
83 (should (let ((text-quoting-style 'straight))
84 (string= (substitute-command-keys "quotes `like this'")
85 "quotes 'like this'")))
86 ;; Bugs.
87 (should (string= (substitute-command-keys "\\[foobar") "\\[foobar"))
88 (should (string= (substitute-command-keys "\\=") "\\="))
89 )
90
91(provide 'doc-tests)
92;;; doc-tests.el ends here