summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/checkdoc-tests.el
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-09-26 01:20:55 +0200
committerStefan Kangas <stefan@marxist.se>2021-09-28 01:12:36 +0200
commit3cabf64131b93e1b0510a01bcce8efde38b20bc4 (patch)
tree5f4cc8d403d690e614f799214df31ff58ac6b6bc /test/lisp/emacs-lisp/checkdoc-tests.el
parent6bec21243d20df015875ee8576bc722224480acb (diff)
downloademacs-3cabf64131b93e1b0510a01bcce8efde38b20bc4.tar.gz
emacs-3cabf64131b93e1b0510a01bcce8efde38b20bc4.tar.bz2
emacs-3cabf64131b93e1b0510a01bcce8efde38b20bc4.zip
checkdoc: Allow Lisp symbols to start a message
* lisp/emacs-lisp/checkdoc.el (checkdoc-message-text-engine): Allow Lisp symbols to start a message. (checkdoc--error-bad-format-p): New helper function. * test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-test-error-format-is-good) (checkdoc-test-error-format-is-bad): New helper functions. (checkdoc-tests-error-message-bad-format-p) (checkdoc-tests-error-message-bad-format-p/defined-symbols) (checkdoc-tests-error-message-bad-format-p/not-capitalized): New tests.
Diffstat (limited to 'test/lisp/emacs-lisp/checkdoc-tests.el')
-rw-r--r--test/lisp/emacs-lisp/checkdoc-tests.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el b/test/lisp/emacs-lisp/checkdoc-tests.el
index d452024b8ff..ef49e71599a 100644
--- a/test/lisp/emacs-lisp/checkdoc-tests.el
+++ b/test/lisp/emacs-lisp/checkdoc-tests.el
@@ -151,6 +151,43 @@ See the comments in Bug#24998."
(ert-deftest checkdoc-tests-in-abbrevation-p/incorrect-abbreviation ()
(should-not (checkdoc-tests--abbrev-test "foo bar a.b.c." "a.b.c")))
+(defun checkdoc-test-error-format-is-good (msg &optional reverse literal)
+ (with-temp-buffer
+ (erase-buffer)
+ (emacs-lisp-mode)
+ (let ((standard-output (current-buffer)))
+ (if literal
+ (print (format "(error \"%s\")" msg))
+ (prin1 `(error ,msg))))
+ (goto-char (length "(error \""))
+ (if reverse
+ (should (checkdoc--error-bad-format-p))
+ (should-not (checkdoc--error-bad-format-p)))))
+
+(defun checkdoc-test-error-format-is-bad (msg &optional literal)
+ (checkdoc-test-error-format-is-good msg t literal))
+
+(ert-deftest checkdoc-tests-error-message-bad-format-p ()
+ (checkdoc-test-error-format-is-good "Foo")
+ (checkdoc-test-error-format-is-good "Foo: bar baz")
+ (checkdoc-test-error-format-is-good "some-symbol: Foo")
+ (checkdoc-test-error-format-is-good "`some-symbol' foo bar")
+ (checkdoc-test-error-format-is-good "%sfoo")
+ (checkdoc-test-error-format-is-good "avl-tree-enter:\\
+ Updated data does not match existing data" nil 'literal))
+
+(ert-deftest checkdoc-tests-error-message-bad-format-p/defined-symbols ()
+ (defvar checkdoc-tests--var-symbol nil)
+ (checkdoc-test-error-format-is-good "checkdoc-tests--var-symbol foo bar baz")
+ (defun checkdoc-tests--fun-symbol ())
+ (checkdoc-test-error-format-is-good "checkdoc-tests--fun-symbol foo bar baz"))
+
+(ert-deftest checkdoc-tests-error-message-bad-format-p/not-capitalized ()
+ (checkdoc-test-error-format-is-bad "foo")
+ (checkdoc-test-error-format-is-bad "some-symbol: foo")
+ (checkdoc-test-error-format-is-bad "avl-tree-enter:\
+ updated data does not match existing data"))
+
(ert-deftest checkdoc-tests-fix-y-or-n-p ()
(with-temp-buffer
(emacs-lisp-mode)