summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorDaniel Martín <mardani29@yahoo.es>2023-03-12 13:38:34 +0100
committerEli Zaretskii <eliz@gnu.org>2023-03-12 15:22:38 +0200
commitd19416d15c29368112fba9a7437930abcec9af3b (patch)
treec5df370d894a4a9bf9884c55652637c513f52e0e /test/lisp/emacs-lisp
parent9191fd50d242cde5256b876dd756ffbc6f46db90 (diff)
downloademacs-d19416d15c29368112fba9a7437930abcec9af3b.tar.gz
Fix pluralization in shortdoc-help-fns-examples-function
* lisp/emacs-lisp/shortdoc.el (shortdoc-help-fns-examples-function): Implement a better logic to pluralize "Example", by counting the number of arrow characters in the example string. (Bug#61877) * test/lisp/emacs-lisp/shortdoc-tests.el (shortdoc-help-fns-examples-function-test): Add a test.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/shortdoc-tests.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/shortdoc-tests.el b/test/lisp/emacs-lisp/shortdoc-tests.el
index a65a4a5ddc3..d2dfbc66864 100644
--- a/test/lisp/emacs-lisp/shortdoc-tests.el
+++ b/test/lisp/emacs-lisp/shortdoc-tests.el
@@ -75,6 +75,21 @@
(should (equal '((regexp . "(string-match-p \"^[fo]+\" \"foobar\")\n => 0"))
(shortdoc-function-examples 'string-match-p))))
+(ert-deftest shortdoc-help-fns-examples-function-test ()
+ "Test that `shortdoc-help-fns-examples-function' correctly prints ELisp function examples."
+ (with-temp-buffer
+ (shortdoc-help-fns-examples-function 'string-fill)
+ (should (equal "\n Examples:\n\n (string-fill \"Three short words\" 12)\n => \"Three short\\nwords\"\n (string-fill \"Long-word\" 3)\n => \"Long-word\"\n\n"
+ (buffer-substring-no-properties (point-min) (point-max))))
+ (erase-buffer)
+ (shortdoc-help-fns-examples-function 'assq)
+ (should (equal "\n Examples:\n\n (assq 'foo '((foo . bar) (zot . baz)))\n => (foo . bar)\n\n (assq 'b '((a . 1) (b . 2)))\n => (b . 2)\n\n"
+ (buffer-substring-no-properties (point-min) (point-max))))
+ (erase-buffer)
+ (shortdoc-help-fns-examples-function 'string-trim)
+ (should (equal "\n Example:\n\n (string-trim \" foo \")\n => \"foo\"\n\n"
+ (buffer-substring-no-properties (point-min) (point-max))))))
+
(provide 'shortdoc-tests)
;;; shortdoc-tests.el ends here