summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-09-16 19:13:56 +0200
committerStefan Kangas <stefan@marxist.se>2021-09-17 22:24:12 +0200
commitb6bff3ba7971daad737690d88a3921f1dd190476 (patch)
tree3193668b29522417eb4566c45f50c534d7d95051 /test/lisp/emacs-lisp
parent174430e35186b1554eafe6ab1227ab9697224a56 (diff)
downloademacs-b6bff3ba7971daad737690d88a3921f1dd190476.tar.gz
emacs-b6bff3ba7971daad737690d88a3921f1dd190476.tar.bz2
emacs-b6bff3ba7971daad737690d88a3921f1dd190476.zip
checkdoc: 'y-or-n-p' no longer needs space
* lisp/emacs-lisp/checkdoc.el (checkdoc-message-text-engine): Change 'y-or-n-p' check to accept prompt ending with both "? " or "?", that is, it no longer needs the space. (Bug#50621) (checkdoc--fix-y-or-n-p): New helper function. * test/lisp/emacs-lisp/checkdoc-tests.el (checkdoc-tests-fix-y-or-n-p) (checkdoc-tests-fix-y-or-n-p/no-change) (checkdoc-tests-fix-y-or-n-p/with-space): New tests.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/checkdoc-tests.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el b/test/lisp/emacs-lisp/checkdoc-tests.el
index a4b252031fe..3eb7da3d4a7 100644
--- a/test/lisp/emacs-lisp/checkdoc-tests.el
+++ b/test/lisp/emacs-lisp/checkdoc-tests.el
@@ -146,4 +146,34 @@ See the comments in Bug#24998."
(re-search-forward "e.g")
(should (checkdoc-in-abbreviation-p (point)))))
+(ert-deftest checkdoc-tests-fix-y-or-n-p ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (let ((standard-output (current-buffer))
+ (checkdoc-autofix-flag 'automatic))
+ (prin1 '(y-or-n-p "foo")) ; "foo"
+ (goto-char (length "(y-or-n-p "))
+ (checkdoc--fix-y-or-n-p)
+ (should (equal (buffer-string) "(y-or-n-p \"foo?\")")))))
+
+(ert-deftest checkdoc-tests-fix-y-or-n-p/no-change ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (let ((standard-output (current-buffer))
+ (checkdoc-autofix-flag 'automatic))
+ (prin1 '(y-or-n-p "foo?")) ; "foo?"
+ (goto-char (length "(y-or-n-p "))
+ (checkdoc--fix-y-or-n-p)
+ (should (equal (buffer-string) "(y-or-n-p \"foo?\")")))))
+
+(ert-deftest checkdoc-tests-fix-y-or-n-p/with-space ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (let ((standard-output (current-buffer))
+ (checkdoc-autofix-flag 'automatic))
+ (prin1 '(y-or-n-p "foo? ")) ; "foo? "
+ (goto-char (length "(y-or-n-p "))
+ (checkdoc--fix-y-or-n-p)
+ (should (equal (buffer-string) "(y-or-n-p \"foo? \")")))))
+
;;; checkdoc-tests.el ends here