diff options
| author | Damien Cassou | 2019-10-10 02:19:10 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-10 02:19:10 +0200 |
| commit | 46d11bcfa381c13a9719b7ecd3f9d4cc92c34089 (patch) | |
| tree | 9c76c23bb527fa3b8934806bd57e66612ccc59d6 | |
| parent | b9211d0bc2b0adcef5fd84cc3904ad46818fec73 (diff) | |
| download | emacs-46d11bcfa381c13a9719b7ecd3f9d4cc92c34089.tar.gz emacs-46d11bcfa381c13a9719b7ecd3f9d4cc92c34089.zip | |
checkdoc CL tests
* test/lisp/emacs-lisp/checkdoc-tests.el: Add cl-lib-related tests
(bug#37063).
| -rw-r--r-- | test/lisp/emacs-lisp/checkdoc-tests.el | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el b/test/lisp/emacs-lisp/checkdoc-tests.el index 1cefc4c3662..de75c42c520 100644 --- a/test/lisp/emacs-lisp/checkdoc-tests.el +++ b/test/lisp/emacs-lisp/checkdoc-tests.el | |||
| @@ -37,6 +37,112 @@ | |||
| 37 | (insert "(defun foo())") | 37 | (insert "(defun foo())") |
| 38 | (should-error (checkdoc-defun) :type 'user-error))) | 38 | (should-error (checkdoc-defun) :type 'user-error))) |
| 39 | 39 | ||
| 40 | (ert-deftest checkdoc-cl-defmethod-ok () | ||
| 41 | "Checkdoc should be happy with a simple correct cl-defmethod." | ||
| 42 | (with-temp-buffer | ||
| 43 | (emacs-lisp-mode) | ||
| 44 | (insert "(cl-defmethod foo (a) \"Return A.\")") | ||
| 45 | (checkdoc-defun))) | ||
| 46 | |||
| 47 | (ert-deftest checkdoc-cl-defmethod-with-types-ok () | ||
| 48 | "Checkdoc should be happy with a cl-defmethod using types." | ||
| 49 | (with-temp-buffer | ||
| 50 | (emacs-lisp-mode) | ||
| 51 | ;; this method matches if A is the symbol `smthg' and if b is a list: | ||
| 52 | (insert "(cl-defmethod foo ((a (eql smthg)) (b list)) \"Return A+B.\")") | ||
| 53 | (checkdoc-defun))) | ||
| 54 | |||
| 55 | (ert-deftest checkdoc-cl-defun-with-key-ok () | ||
| 56 | "Checkdoc should be happy with a cl-defun using &key." | ||
| 57 | (with-temp-buffer | ||
| 58 | (emacs-lisp-mode) | ||
| 59 | (insert "(cl-defun foo (&key a (b 27)) \"Return :A+:B.\")") | ||
| 60 | (checkdoc-defun))) | ||
| 61 | |||
| 62 | (ert-deftest checkdoc-cl-defun-with-allow-other-keys-ok () | ||
| 63 | "Checkdoc should be happy with a cl-defun using &allow-other-keys." | ||
| 64 | (with-temp-buffer | ||
| 65 | (emacs-lisp-mode) | ||
| 66 | (insert "(cl-defun foo (&key a &allow-other-keys) \"Return :A.\")") | ||
| 67 | (checkdoc-defun))) | ||
| 68 | |||
| 69 | (ert-deftest checkdoc-cl-defun-with-default-optional-value-ok () | ||
| 70 | "Checkdoc should be happy with a cl-defun using default values for optional args." | ||
| 71 | (with-temp-buffer | ||
| 72 | (emacs-lisp-mode) | ||
| 73 | ;; B is optional and equals 1+a if not provided. HAS-BS is non-nil | ||
| 74 | ;; if B was provided in the call: | ||
| 75 | (insert "(cl-defun foo (a &optional (b (1+ a) has-bs)) \"Return A + B.\")") | ||
| 76 | (checkdoc-defun))) | ||
| 77 | |||
| 78 | (ert-deftest checkdoc-cl-defun-with-destructuring-ok () | ||
| 79 | "Checkdoc should be happy with a cl-defun destructuring its arguments." | ||
| 80 | (with-temp-buffer | ||
| 81 | (emacs-lisp-mode) | ||
| 82 | (insert "(cl-defun foo ((a b &optional c) d) \"Return A+B+C+D.\")") | ||
| 83 | (checkdoc-defun))) | ||
| 84 | |||
| 85 | (ert-deftest checkdoc-cl-defmethod-ok () | ||
| 86 | "Checkdoc should be happy with a simple correct cl-defmethod." | ||
| 87 | (with-temp-buffer | ||
| 88 | (emacs-lisp-mode) | ||
| 89 | (insert "(cl-defmethod foo (a) \"Return A.\")") | ||
| 90 | (checkdoc-defun))) | ||
| 91 | |||
| 92 | (ert-deftest checkdoc-cl-defmethod-with-types-ok () | ||
| 93 | "Checkdoc should be happy with a cl-defmethod using types." | ||
| 94 | (with-temp-buffer | ||
| 95 | (emacs-lisp-mode) | ||
| 96 | ;; this method matches if A is the symbol `smthg' and if b is a list: | ||
| 97 | (insert "(cl-defmethod foo ((a (eql smthg)) (b list)) \"Return A+B.\")") | ||
| 98 | (checkdoc-defun))) | ||
| 99 | |||
| 100 | (ert-deftest checkdoc-cl-defun-with-key-ok () | ||
| 101 | "Checkdoc should be happy with a cl-defun using &key." | ||
| 102 | (with-temp-buffer | ||
| 103 | (emacs-lisp-mode) | ||
| 104 | (insert "(cl-defun foo (&key a (b 27)) \"Return :A+:B.\")") | ||
| 105 | (checkdoc-defun))) | ||
| 106 | |||
| 107 | (ert-deftest checkdoc-cl-defun-with-allow-other-keys-ok () | ||
| 108 | "Checkdoc should be happy with a cl-defun using &allow-other-keys." | ||
| 109 | (with-temp-buffer | ||
| 110 | (emacs-lisp-mode) | ||
| 111 | (insert "(cl-defun foo (&key a &allow-other-keys) \"Return :A.\")") | ||
| 112 | (checkdoc-defun))) | ||
| 113 | |||
| 114 | (ert-deftest checkdoc-cl-defun-with-aux-ok () | ||
| 115 | "Checkdoc should be happy with a cl-defun using &aux." | ||
| 116 | (with-temp-buffer | ||
| 117 | (emacs-lisp-mode) | ||
| 118 | (insert "(cl-defun foo (a b &aux (c (+ a b))) \"Return A and B.\")") | ||
| 119 | (checkdoc-defun))) | ||
| 120 | |||
| 121 | (ert-deftest checkdoc-cl-defun-with-default-optional-value-ok () | ||
| 122 | "Checkdoc should be happy with a cl-defun using default values for optional args." | ||
| 123 | (with-temp-buffer | ||
| 124 | (emacs-lisp-mode) | ||
| 125 | ;; B is optional and equals 1+a if not provided. HAS-BS is non-nil | ||
| 126 | ;; if B was provided in the call: | ||
| 127 | (insert "(cl-defun foo (a &optional (b (1+ a) has-bs)) \"Return A + B.\")") | ||
| 128 | (checkdoc-defun))) | ||
| 129 | |||
| 130 | (ert-deftest checkdoc-cl-defun-with-destructuring-ok () | ||
| 131 | "Checkdoc should be happy with a cl-defun destructuring its arguments." | ||
| 132 | (with-temp-buffer | ||
| 133 | (emacs-lisp-mode) | ||
| 134 | (insert "(cl-defun foo ((a b &optional c) d) \"Return A+B+C+D.\")") | ||
| 135 | (checkdoc-defun))) | ||
| 136 | |||
| 137 | (ert-deftest checkdoc-cl-defmethod-with-context-ok () | ||
| 138 | "Checkdoc should ignore context specializers in a cl-defmethod." | ||
| 139 | (with-temp-buffer | ||
| 140 | (emacs-lisp-mode) | ||
| 141 | ;; A context specializer is used to select the correct method but | ||
| 142 | ;; doesn't have to appear in the docstring: | ||
| 143 | (insert "(cl-defmethod foo (a &context (global-var (eql foo))) \"Return A.\")") | ||
| 144 | (checkdoc-defun))) | ||
| 145 | |||
| 40 | (ert-deftest checkdoc-tests--next-docstring () | 146 | (ert-deftest checkdoc-tests--next-docstring () |
| 41 | "Checks that the one-argument form of `defvar' works. | 147 | "Checks that the one-argument form of `defvar' works. |
| 42 | See the comments in Bug#24998." | 148 | See the comments in Bug#24998." |