aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJuanma Barranquero2019-11-23 23:29:53 +0100
committerJuanma Barranquero2019-11-23 23:29:53 +0100
commit6f3ff47c521a41f3eab3efd1f6126f06f4171478 (patch)
tree3dc30a4fa7a2d75cfaf0702c3a6dc6520ead0726 /test
parent4b5d04be44af36cb2faccd368de063cf376282ca (diff)
downloademacs-6f3ff47c521a41f3eab3efd1f6126f06f4171478.tar.gz
emacs-6f3ff47c521a41f3eab3efd1f6126f06f4171478.zip
Make help-split-fundoc more flexible about what returns
* lisp/help.el (help-split-fundoc): New arg SECTION to return only the usage or doc parts of the docstring, or both even if there is no usage. * test/lisp/help-tests.el: New file.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/help-tests.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el
new file mode 100644
index 00000000000..28dd8830e44
--- /dev/null
+++ b/test/lisp/help-tests.el
@@ -0,0 +1,56 @@
1;;; help-tests.el --- Tests for help.el -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; Author: Juanma Barranquero <lekktu@gmail.com>
6;; Keywords: help, internal
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22
23;;; Code:
24
25(require 'ert)
26
27(ert-deftest help-split-fundoc-SECTION ()
28 "Test new optional arg SECTION."
29 (let* ((doc "Doc first line.\nDoc second line.")
30 (usg "\n\n(fn ARG1 &optional ARG2)")
31 (full (concat doc usg))
32 (usage "(t ARG1 &optional ARG2)"))
33 ;; Docstring has both usage and doc
34 (should (equal (help-split-fundoc full t nil) `(,usage . ,doc)))
35 (should (equal (help-split-fundoc full t t) `(,usage . ,doc)))
36 (should (equal (help-split-fundoc full t 'usage) usage))
37 (should (equal (help-split-fundoc full t 'doc) doc))
38 ;; Docstring has no usage, only doc
39 (should (equal (help-split-fundoc doc t nil) nil))
40 (should (equal (help-split-fundoc doc t t) `(nil . ,doc)))
41 (should (equal (help-split-fundoc doc t 'usage) nil))
42 (should (equal (help-split-fundoc doc t 'doc) doc))
43 ;; Docstring is only usage, no doc
44 (should (equal (help-split-fundoc usg t nil) `(,usage . nil)))
45 (should (equal (help-split-fundoc usg t t) `(,usage . nil)))
46 (should (equal (help-split-fundoc usg t 'usage) usage))
47 (should (equal (help-split-fundoc usg t 'doc) nil))
48 ;; Docstring is null
49 (should (equal (help-split-fundoc nil t nil) nil))
50 (should (equal (help-split-fundoc nil t t) '(nil)))
51 (should (equal (help-split-fundoc nil t 'usage) nil))
52 (should (equal (help-split-fundoc nil t 'doc) nil))))
53
54(provide 'help-tests)
55
56;;; help-tests.el ends here