1 ;;; help-fns.el --- tests for help-fns.el
3 ;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
5 ;; Maintainer: emacs-devel@gnu.org
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
28 (autoload 'help-fns-test--macro
"help-fns" nil nil t
)
31 ;;; Several tests for describe-function
33 (defun help-fns-tests--describe-function (func)
34 "Helper function for `describe-function' tests.
35 FUNC is the function to describe, a symbol.
36 Return first line of the output of (describe-function-1 FUNC)."
37 (let ((string (with-output-to-string
38 (describe-function-1 func
))))
39 (string-match "\\(.+\\)\n" string
)
40 (match-string-no-properties 1 string
)))
42 (ert-deftest help-fns-test-bug17410
()
43 "Test for https://debbugs.gnu.org/17410 ."
44 (let ((regexp "autoloaded Lisp macro")
45 (result (help-fns-tests--describe-function 'help-fns-test--macro
)))
46 (should (string-match regexp result
))))
48 (ert-deftest help-fns-test-built-in
()
49 (let ((regexp "a built-in function in .C source code")
50 (result (help-fns-tests--describe-function 'mapcar
)))
51 (should (string-match regexp result
))))
53 (ert-deftest help-fns-test-interactive-built-in
()
54 (let ((regexp "an interactive built-in function in .C source code")
55 (result (help-fns-tests--describe-function 're-search-forward
)))
56 (should (string-match regexp result
))))
58 (ert-deftest help-fns-test-lisp-macro
()
59 (let ((regexp "a Lisp macro in .subr\.el")
60 (result (help-fns-tests--describe-function 'when
)))
61 (should (string-match regexp result
))))
63 (ert-deftest help-fns-test-lisp-defun
()
64 (let ((regexp "a compiled Lisp function in .subr\.el")
65 (result (help-fns-tests--describe-function 'last
)))
66 (should (string-match regexp result
))))
68 (ert-deftest help-fns-test-lisp-defsubst
()
69 (let ((regexp "a compiled Lisp function in .subr\.el")
70 (result (help-fns-tests--describe-function 'posn-window
)))
71 (should (string-match regexp result
))))
73 (ert-deftest help-fns-test-alias-to-defun
()
74 (let ((regexp "an alias for .set-file-modes. in .subr\.el")
75 (result (help-fns-tests--describe-function 'chmod
)))
76 (should (string-match regexp result
))))
78 (ert-deftest help-fns-test-bug23887
()
79 "Test for https://debbugs.gnu.org/23887 ."
80 (let ((regexp "an alias for .re-search-forward. in .subr\.el")
81 (result (help-fns-tests--describe-function 'search-forward-regexp
)))
82 (should (string-match regexp result
))))
84 (ert-deftest help-fns-test-dangling-alias
()
85 "Make sure we don't burp on bogus aliases."
86 (let ((f (make-symbol "bogus-alias")))
87 (define-obsolete-function-alias f
'help-fns-test--undefined-function
"past")
90 ;;; Test describe-function over functions with funny names
91 (defun abc\\\
[universal-argument\
]b\
`c
\'d
\\e
\"f
(x)
92 "A function with a funny name.
97 (defun defgh\\\
[universal-argument\
]b\
`c
\'d
\\e
\"f
(x)
98 "Another function with a funny name."
101 (ert-deftest help-fns-test-funny-names
()
102 "Test for help with functions with funny names."
103 (describe-function 'abc
\\\
[universal-argument\
]b\
`c
\'d
\\e
\"f
)
104 (with-current-buffer "*Help*"
105 (goto-char (point-min))
106 (should (search-forward
107 "(abc\\\\\\[universal-argument\\]b\\`c\\'d\\\\e\\\"f XYZZY)")))
108 (describe-function 'defgh
\\\
[universal-argument\
]b\
`c
\'d
\\e
\"f
)
109 (with-current-buffer "*Help*"
110 (goto-char (point-min))
111 (should (search-forward
112 "(defgh\\\\\\[universal-argument\\]b\\`c\\'d\\\\e\\\"f X)"))))
115 ;;; Test for describe-symbol
116 (ert-deftest help-fns-test-describe-symbol
()
117 "Test the `describe-symbol' function."
118 ;; 'describe-symbol' would originally signal an error for
119 ;; 'font-lock-comment-face'.
120 (describe-symbol 'font-lock-comment-face
)
121 (with-current-buffer "*Help*"
122 (should (> (point-max) 1))
123 (goto-char (point-min))
124 (should (looking-at "^font-lock-comment-face is "))))
126 ;;; help-fns.el ends here