aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPhilipp Stephani2016-12-30 18:00:54 +0100
committerPhilipp Stephani2016-12-31 17:30:46 +0100
commit4bbd5424a2290ab4bd88c0af602b7aa7d53a407e (patch)
treec6928916fdb29df58d509e519953adc1fe21f6a3 /test
parent8a165813cb9321a8979ac6d98530f5e4392fb879 (diff)
downloademacs-4bbd5424a2290ab4bd88c0af602b7aa7d53a407e.tar.gz
emacs-4bbd5424a2290ab4bd88c0af602b7aa7d53a407e.zip
Checkdoc: use syntax functions instead of regex
In checkdoc.el, get rid of the error-prone regex to find definition forms, and use existing syntax-based navigation functions instead. This fixes a corner case with one-argument `defvar' forms. * lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): New function. (checkdoc-next-docstring, checkdoc-defun): Use it. * test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-tests--next-docstring): Add unit test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/checkdoc-tests.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el b/test/lisp/emacs-lisp/checkdoc-tests.el
index 18b5a499e08..02db88c17e2 100644
--- a/test/lisp/emacs-lisp/checkdoc-tests.el
+++ b/test/lisp/emacs-lisp/checkdoc-tests.el
@@ -37,4 +37,17 @@
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-tests--next-docstring ()
41 "Checks that the one-argument form of `defvar' works.
42See the comments in Bug#24998."
43 (with-temp-buffer
44 (emacs-lisp-mode)
45 (insert "(defvar foo)
46\(defvar foo bar \"baz\")
47\(require 'foo)")
48 (goto-char (point-min))
49 (should (checkdoc-next-docstring))
50 (should (looking-at-p "\"baz\")"))
51 (should-not (checkdoc-next-docstring))))
52
40;;; checkdoc-tests.el ends here 53;;; checkdoc-tests.el ends here