Avoid leaving garbage on screen when using 'raise' display property
[emacs.git] / test / src / doc-tests.el
blob8e5446e2a4b5ab5eb3780e2cf4a00535763a6de1
1 ;;; doc-tests.el --- Tests for doc.c
3 ;; Copyright (C) 2016-2017 Free Software Foundation, Inc.
5 ;; Author: Eli Zaretskii <eliz@gnu.org>
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.
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.
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/>.
20 ;;; Code:
22 (require 'ert)
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}")
41 key binding
42 --- -------
44 C-g abort-recursive-edit
45 TAB minibuffer-complete
46 C-j minibuffer-complete-and-exit
47 RET minibuffer-complete-and-exit
48 ESC Prefix Command
49 SPC 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
59 M-v switch-to-completions
61 M-n next-history-element
62 M-p previous-history-element
63 M-r previous-matching-history-element
64 M-s next-matching-history-element
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 "\\=") "\\="))
91 (provide 'doc-tests)
92 ;;; doc-tests.el ends here