summaryrefslogtreecommitdiff
path: root/test/lisp/textmodes
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/textmodes')
-rw-r--r--test/lisp/textmodes/conf-mode-tests.el5
-rw-r--r--test/lisp/textmodes/css-mode-resources/css-selectors.txt56
-rw-r--r--test/lisp/textmodes/css-mode-resources/scss-selectors.txt10
-rw-r--r--test/lisp/textmodes/css-mode-tests.el69
-rw-r--r--test/lisp/textmodes/emacs-news-mode-resources/toggle-tag.erts131
-rw-r--r--test/lisp/textmodes/emacs-news-mode-tests.el32
-rw-r--r--test/lisp/textmodes/fill-tests.el30
-rw-r--r--test/lisp/textmodes/page-tests.el12
-rw-r--r--test/lisp/textmodes/reftex-tests.el409
-rw-r--r--test/lisp/textmodes/texinfo-resources/fill.erts70
-rw-r--r--test/lisp/textmodes/texinfo-tests.el33
11 files changed, 796 insertions, 61 deletions
diff --git a/test/lisp/textmodes/conf-mode-tests.el b/test/lisp/textmodes/conf-mode-tests.el
index 2b4fde40c34..097b25f1144 100644
--- a/test/lisp/textmodes/conf-mode-tests.el
+++ b/test/lisp/textmodes/conf-mode-tests.el
@@ -74,8 +74,7 @@ PersistMoniker=file://Folder.htt")
(ert-deftest conf-test-javaprop-mode ()
(with-temp-buffer
;; From `conf-javaprop-mode' docstring
- (insert "// another kind of comment
-/* yet another */
+ (insert "# comment
name:value
name=value
@@ -90,8 +89,6 @@ x.2.y.1.z.2.zz =")
(should (equal (face-at-point) 'font-lock-comment-delimiter-face))
(forward-char 3)
(should (equal (face-at-point) 'font-lock-comment-face))
- (search-forward "*")
- (should (equal (face-at-point) 'font-lock-comment-delimiter-face))
(while (search-forward "nam" nil t)
(should (equal (face-at-point) 'font-lock-variable-name-face))
(search-forward "val")
diff --git a/test/lisp/textmodes/css-mode-resources/css-selectors.txt b/test/lisp/textmodes/css-mode-resources/css-selectors.txt
new file mode 100644
index 00000000000..5b3d990f279
--- /dev/null
+++ b/test/lisp/textmodes/css-mode-resources/css-selectors.txt
@@ -0,0 +1,56 @@
+#firstname
+*
+p
+p.intro
+div, p
+div p
+div > p
+div + p
+p ~ ul
+[target]
+[target=_blank]
+[title~=flower]
+[lang|=en]
+a[href^="https"]
+a[href$=".pdf"]
+a[href*="w3schools"]
+a:active
+p::after
+p::before
+input:checked
+input:default
+input:disabled
+p:empty
+input:enabled
+p:first-child
+p::first-letter
+p::first-line
+p:first-of-type
+input:focus
+:fullscreen
+a:hover
+input:in-range
+input:indeterminate
+input:invalid
+p:lang(it)
+p:last-child
+p:last-of-type
+a:link
+::marker
+:not(p)
+p:nth-child(2)
+p:nth-last-child(2)
+p:nth-last-of-type(2)
+p:nth-of-type(2)
+p:only-of-type
+p:only-child
+input:optional
+input:out-of-range
+input:read-only
+input:read-write
+input:required
+:root
+::selection
+#news:target
+input:valid
+a:visited
diff --git a/test/lisp/textmodes/css-mode-resources/scss-selectors.txt b/test/lisp/textmodes/css-mode-resources/scss-selectors.txt
new file mode 100644
index 00000000000..3e05191a910
--- /dev/null
+++ b/test/lisp/textmodes/css-mode-resources/scss-selectors.txt
@@ -0,0 +1,10 @@
+p.#{$name} var
+p.#{$name}:active var
+p.#{$name}::after var
+f.#{$bar}::after p::after
+p.#{$name} f.#{$bar} k.var #{$bar} #{$bar}
+p.#{$name}
+&:hover
+> li
++ li
+~ li
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el
index 0ae1593508d..1d2d556992b 100644
--- a/test/lisp/textmodes/css-mode-tests.el
+++ b/test/lisp/textmodes/css-mode-tests.el
@@ -419,5 +419,74 @@
(indent-region (point-min) (point-max))
(should (equal (buffer-string) orig)))))
+(ert-deftest css-mode-test-selectors ()
+ (let ((selectors
+ (with-temp-buffer
+ (insert-file-contents (ert-resource-file "css-selectors.txt"))
+ (string-lines (buffer-string)))))
+ (with-suppressed-warnings ((interactive-only font-lock-debug-fontify))
+ (dolist (selector selectors)
+ (with-temp-buffer
+ (css-mode)
+ (insert selector " {\n}\n")
+ (font-lock-debug-fontify)
+ (goto-char (point-min))
+ (unless (eq (get-text-property (point) 'face)
+ 'css-selector)
+ (should-not (format "Didn't recognize %s as a selector"
+ (buffer-substring-no-properties
+ (point) (pos-eol)))))))
+ ;; Test many selectors.
+ (dolist (selector selectors)
+ (with-temp-buffer
+ (css-mode)
+ (insert selector " ")
+ (dotimes (_ (random 5))
+ (insert (seq-random-elt '(" , " " > " " + "))
+ (seq-random-elt selectors)))
+ (insert "{\n}\n")
+ (font-lock-debug-fontify)
+ (goto-char (point-min))
+ (unless (eq (get-text-property (point) 'face)
+ 'css-selector)
+ (should-not (format "Didn't recognize %s as a selector"
+ (buffer-substring-no-properties
+ (point) (pos-eol)))))))
+ ;; Test wrong separators.
+ (dolist (selector selectors)
+ (with-temp-buffer
+ (css-mode)
+ (insert selector " ")
+ (dotimes (_ (1+ (random 5)))
+ (insert (seq-random-elt '("=" " @ "))
+ (seq-random-elt selectors)))
+ (insert "{\n}\n")
+ (font-lock-debug-fontify)
+ (goto-char (point-min))
+ (when (eq (get-text-property (point) 'face)
+ 'css-selector)
+ (should-not (format "Recognized %s as a selector"
+ (buffer-substring-no-properties
+ (point) (pos-eol))))))))))
+
+(ert-deftest scss-mode-test-selectors ()
+ (let ((selectors
+ (with-temp-buffer
+ (insert-file-contents (ert-resource-file "scss-selectors.txt"))
+ (string-lines (buffer-string)))))
+ (with-suppressed-warnings ((interactive-only font-lock-debug-fontify))
+ (dolist (selector selectors)
+ (with-temp-buffer
+ (scss-mode)
+ (insert selector " {\n}\n")
+ (font-lock-debug-fontify)
+ (goto-char (point-min))
+ (unless (eq (get-text-property (point) 'face)
+ 'css-selector)
+ (should-not (format "Didn't recognize %s as a selector"
+ (buffer-substring-no-properties
+ (point) (pos-eol))))))))))
+
+
(provide 'css-mode-tests)
;;; css-mode-tests.el ends here
diff --git a/test/lisp/textmodes/emacs-news-mode-resources/toggle-tag.erts b/test/lisp/textmodes/emacs-news-mode-resources/toggle-tag.erts
new file mode 100644
index 00000000000..63c3b1b7d8a
--- /dev/null
+++ b/test/lisp/textmodes/emacs-news-mode-resources/toggle-tag.erts
@@ -0,0 +1,131 @@
+Name: tag1
+Point-Char: |
+
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+|Before, that binding was only available with 'dired-x'.
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+---
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+|Before, that binding was only available with 'dired-x'.
+=-=-=
+
+Name: tag2
+Point-Char: |
+
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+---
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+|Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
++++
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+|Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=-=
+
+Name: tag3
+Point-Char: |
+
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
++++
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+|Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+|Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=-=
+
+Name: tag4-point-at-headline
+Point-Char: |
+
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+|*** 'M-G' is now bound to 'dired-goto-subdir'.
+Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+---
+|*** 'M-G' is now bound to 'dired-goto-subdir'.
+Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=-=
+
+Name: tag5-point-at-tag
+Point-Char: |
+
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+|---
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+|+++
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=-=
+
+Name: tag6-point-at-tag
+Point-Char: |
+
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+|+++
+*** 'M-G' is now bound to 'dired-goto-subdir'.
+Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=
++++
+*** 'dired-do-relsymlink-regexp' moved from dired-x to dired.
+The corresponding key "% Y" is now bound by default in Dired.
+
+|*** 'M-G' is now bound to 'dired-goto-subdir'.
+Before, that binding was only available if the 'dired-x' package was
+loaded.
+=-=-=
diff --git a/test/lisp/textmodes/emacs-news-mode-tests.el b/test/lisp/textmodes/emacs-news-mode-tests.el
new file mode 100644
index 00000000000..d2da5eda906
--- /dev/null
+++ b/test/lisp/textmodes/emacs-news-mode-tests.el
@@ -0,0 +1,32 @@
+;;; emacs-news-mode-tests.el --- Tests for emacs-news-mode.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'ert-x)
+(require 'emacs-news-mode)
+
+(ert-deftest emacs-news-toggle-tag ()
+ (ert-test-erts-file (ert-resource-file "toggle-tag.erts")
+ (lambda ()
+ (emacs-news-mode)
+ (emacs-news-toggle-tag))))
+
+;;; emacs-news-mode-tests.el ends here
diff --git a/test/lisp/textmodes/fill-tests.el b/test/lisp/textmodes/fill-tests.el
index 8b9f144dfff..f2a0daf8122 100644
--- a/test/lisp/textmodes/fill-tests.el
+++ b/test/lisp/textmodes/fill-tests.el
@@ -53,8 +53,8 @@
(goto-char (point-min))
(search-forward "b")
(let* ((pos (point))
- (beg (line-beginning-position))
- (end (line-end-position))
+ (beg (pos-bol))
+ (end (pos-eol))
(fill-prefix (make-string (- pos beg) ?\s))
;; `fill-column' is too small to accommodate the current line
(fill-column (- end beg 10)))
@@ -68,8 +68,8 @@
(goto-char (point-min))
(search-forward "b")
(let* ((pos (point))
- (beg (line-beginning-position))
- (end (line-end-position))
+ (beg (pos-bol))
+ (end (pos-eol))
(fill-prefix (make-string (- pos beg) ?\s))
;; `fill-column' is too small to accommodate the current line
(fill-column (- end beg 10)))
@@ -78,6 +78,28 @@
(buffer-string)
"aaa = baaaaaaaa aaaaaaaaaa\n aaaaaaaaaa\n")))))
+(ert-deftest test-fill-end-period ()
+ (should
+ (equal
+ (with-temp-buffer
+ (text-mode)
+ (auto-fill-mode)
+ (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eius.")
+ (self-insert-command 1 ?\s)
+ (buffer-string))
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eius. "))
+ (should
+ (equal
+ (with-temp-buffer
+ (text-mode)
+ (auto-fill-mode)
+ (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eius.Foo")
+ (forward-char -3)
+ (self-insert-command 1 ?\s)
+ (buffer-string))
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
+eius. Foo")))
+
(ert-deftest test-fill-haskell ()
(should
(equal
diff --git a/test/lisp/textmodes/page-tests.el b/test/lisp/textmodes/page-tests.el
index 596f3a6ceb7..b7217e69f0c 100644
--- a/test/lisp/textmodes/page-tests.el
+++ b/test/lisp/textmodes/page-tests.el
@@ -80,6 +80,17 @@
(narrow-to-page 2)
(should (equal (buffer-string) "baz"))
(narrow-to-page -1)
+ (should (equal (buffer-string) "bar\n"))
+
+ (widen)
+ (goto-char (point-min))
+ (narrow-to-page)
+ (should (equal (buffer-string) "foo\n"))
+ (goto-char (point-max))
+ (narrow-to-page 2)
+ (should (equal (buffer-string) "baz"))
+ (goto-char (point-max))
+ (narrow-to-page -1)
(should (equal (buffer-string) "bar\n"))))
(ert-deftest page-tests-count-lines-page ()
@@ -100,4 +111,5 @@
(forward-page)
(should (equal (page--what-page) '(3 4)))))
+
;;; page-tests.el ends here
diff --git a/test/lisp/textmodes/reftex-tests.el b/test/lisp/textmodes/reftex-tests.el
index 0051bf3fd0c..67e01004755 100644
--- a/test/lisp/textmodes/reftex-tests.el
+++ b/test/lisp/textmodes/reftex-tests.el
@@ -24,6 +24,7 @@
;;; Code:
(require 'ert)
+(require 'ert-x)
;;; reftex
(require 'reftex)
@@ -33,32 +34,31 @@
(ert-deftest reftex-locate-bibliography-files ()
"Test `reftex-locate-bibliography-files'."
- (let ((temp-dir (make-temp-file "reftex-bib" 'dir))
- (files '("ref1.bib" "ref2.bib"))
- (test '(("\\addbibresource{ref1.bib}\n" . ("ref1.bib"))
- ("\\\\addbibresource[label=x]{ref2.bib}\\n" . ("ref2.bib"))
- ("\\begin{document}\n\\bibliographystyle{plain}\n
+ (ert-with-temp-directory temp-dir
+ (let ((files '("ref1.bib" "ref2.bib"))
+ (test '(("\\addbibresource{ref1.bib}\n" . ("ref1.bib"))
+ ("\\\\addbibresource[label=x]{ref2.bib}\\n" . ("ref2.bib"))
+ ("\\begin{document}\n\\bibliographystyle{plain}\n
\\bibliography{ref1,ref2}\n\\end{document}" . ("ref1.bib" "ref2.bib"))))
- (reftex-bibliography-commands
- ;; Default value: See reftex-vars.el `reftex-bibliography-commands'
- '("bibliography" "nobibliography" "setupbibtex\\[.*?database="
- "addbibresource")))
- (with-temp-buffer
- (insert "test\n")
+ (reftex-bibliography-commands
+ ;; Default value: See reftex-vars.el `reftex-bibliography-commands'
+ '("bibliography" "nobibliography" "setupbibtex\\[.*?database="
+ "addbibresource")))
+ (with-temp-buffer
+ (insert "test\n")
+ (mapc
+ (lambda (file)
+ (write-region (point-min) (point-max) (expand-file-name file
+ temp-dir)))
+ files))
(mapc
- (lambda (file)
- (write-region (point-min) (point-max) (expand-file-name file
- temp-dir)))
- files))
- (mapc
- (lambda (data)
- (with-temp-buffer
- (insert (car data))
- (let ((res (mapcar #'file-name-nondirectory
- (reftex-locate-bibliography-files temp-dir))))
- (should (equal res (cdr data))))))
- test)
- (delete-directory temp-dir 'recursive)))
+ (lambda (data)
+ (with-temp-buffer
+ (insert (car data))
+ (let ((res (mapcar #'file-name-nondirectory
+ (reftex-locate-bibliography-files temp-dir))))
+ (should (equal res (cdr data))))))
+ test))))
(ert-deftest reftex-what-environment-test ()
"Test `reftex-what-environment'."
@@ -102,12 +102,12 @@
;; reason. (An alternative solution would be to use file-equal-p,
;; but I'm too lazy to do that, as one of the tests compares a
;; list.)
- (let* ((temp-dir (file-truename (make-temp-file "reftex-parse" 'dir)))
- (tex-file (expand-file-name "test.tex" temp-dir))
- (bib-file (expand-file-name "ref.bib" temp-dir)))
- (with-temp-buffer
- (insert
-"\\begin{document}
+ (ert-with-temp-directory temp-dir
+ (let* ((tex-file (expand-file-name "test.tex" temp-dir))
+ (bib-file (expand-file-name "ref.bib" temp-dir)))
+ (with-temp-buffer
+ (insert
+ "\\begin{document}
\\section{test}\\label{sec:test}
\\subsection{subtest}
@@ -118,27 +118,26 @@
\\bibliographystyle{plain}
\\bibliography{ref}
\\end{document}")
- (write-region (point-min) (point-max) tex-file))
- (with-temp-buffer
- (insert "test\n")
- (write-region (point-min) (point-max) bib-file))
- (reftex-ensure-compiled-variables)
- (let ((parsed (reftex-parse-from-file tex-file nil temp-dir)))
- (should (equal (car parsed) `(eof ,tex-file)))
- (pop parsed)
- (while parsed
- (let ((entry (pop parsed)))
- (cond
- ((eq (car entry) 'bib)
- (should (string= (cadr entry) bib-file)))
- ((eq (car entry) 'toc)) ;; ...
- ((string= (car entry) "eq:foo"))
- ((string= (car entry) "sec:test"))
- ((eq (car entry) 'bof)
- (should (string= (cadr entry) tex-file))
- (should (null parsed)))
- (t (should-not t)))))
- (delete-directory temp-dir 'recursive))))
+ (write-region (point-min) (point-max) tex-file))
+ (with-temp-buffer
+ (insert "test\n")
+ (write-region (point-min) (point-max) bib-file))
+ (reftex-ensure-compiled-variables)
+ (let ((parsed (reftex-parse-from-file tex-file nil temp-dir)))
+ (should (equal (car parsed) `(eof ,tex-file)))
+ (pop parsed)
+ (while parsed
+ (let ((entry (pop parsed)))
+ (cond
+ ((eq (car entry) 'bib)
+ (should (string= (cadr entry) bib-file)))
+ ((eq (car entry) 'toc)) ;; ...
+ ((string= (car entry) "eq:foo"))
+ ((string= (car entry) "sec:test"))
+ ((eq (car entry) 'bof)
+ (should (string= (cadr entry) tex-file))
+ (should (null parsed)))
+ (t (should-not t)))))))))
;;; reftex-cite
(require 'reftex-cite)
@@ -191,8 +190,8 @@
(ert-deftest reftex-format-citation-test ()
"Test `reftex-format-citation'."
- (let ((entry (reftex-parse-bibtex-entry
-"@article{Foo13,
+ (let ((entry (reftex-parse-bibtex-entry "\
+@article{Foo13,
author = {Jane Roe and John Doe and Jane Q. Taxpayer},
title = {Some Article},
journal = {Some Journal},
@@ -203,6 +202,310 @@
(should (string= (reftex-format-citation entry "%l:%A:%y:%t %j %P %a")
"Foo13:Jane Roe:2013:Some Article Some Journal 1 Jane Roe, John Doe \\& Jane Taxpayer"))))
+(ert-deftest reftex-all-used-citation-keys ()
+ "Test `reftex-all-used-citation-keys'.
+Take the cite macros provided by biblatex package as reference."
+ (ert-with-temp-directory temp-dir
+ (let ((tex-file (expand-file-name "keys.tex" temp-dir))
+ keys)
+ (with-temp-buffer
+ (insert "\
+\\documentclass{article}
+\\usepackage{biblatex}
+\\begin{document}
+
+Standard commands:
+\\cite[pre][pos]{cite:2022}
+\\Cite[pos]{Cite:2022}
+\\parencite{parencite:2022}
+\\Parencite[pre][]{Parencite:2022}
+\\footcite[][]{footcite:2022}
+\\footcitetext[pre][pos]{footcitetext:2022}
+
+Style specific commands:
+\\textcite{textcite:2022}
+\\Textcite[pos]{Textcite:2022}
+\\smartcite[pre][pos]{smartcite:2022}
+\\Smartcite[pre][]{Smartcite:2022}
+\\cite*[pre][pos]{cite*:2022}
+\\parencite*[][]{parencite*:2022}
+
+Style independent commands:
+\\autocite[pre][pos]{autocite:2022}
+\\autocite*[pos]{autocite*:2022}
+\\Autocite[pre][]{Autocite:2022}
+\\Autocite*{Autocite*:2022}
+
+Text commands:
+\\citeauthor[pre][pos]{citeauthor:2022}
+\\citeauthor*[pre][]{citeauthor*:2022}
+\\Citeauthor[pos]{Citeauthor:2022}
+\\Citeauthor*{Citeauthor*:2022}
+\\citetitle[][]{citetitle:2022}
+\\citetitle*[pre][pos]{citetitle*:2022}
+\\citeyear[pre][pos]{citeyear:2022}
+\\citeyear*[pre][pos]{citeyear*:2022}
+\\citedate[pre][pos]{citedate:2022}
+\\citedate*[pre][pos]{citedate*:2022}
+\\citeurl[pre][pos]{citeurl:2022}
+
+Special commands:
+\\nocite{nocite:2022}
+\\fullcite[pos]{fullcite:2022}
+\\footfullcite[][]{fullfootcite:2022}
+``volcite'' macros have different number of args.
+\\volcite{2}{volcite:2022}
+\\Volcite[pre]{1}{Volcite:2022}
+\\pvolcite{1}[pg]{pvolcite:2022}
+\\Pvolcite[pre]{2}[pg]{Pvolcite:2022}
+\\fvolcite[pre]{3}[pg]{fvolcite:2022}
+\\ftvolcite[pre]{3}[pg]{ftvolcite:2022}
+\\svolcite[pre]{2}[pg]{svolcite:2022}
+\\Svolcite[pre]{4}[pg]{Svolcite:2022}
+\\tvolcite[pre]{5}[pg]{tvolcite:2022}
+\\Tvolcite[pre]{2}[pg]{Tvolcite:2022}
+\\avolcite[pre]{3}[pg]{avolcite:2022}
+\\Avolcite[pre]{1}[pg]{Avolcite:2022}
+\\Notecite[pre]{Notecite:2022}
+\\pnotecite[pre]{pnotecite:2022}
+\\Pnotecite[pre]{Pnotecite:2022}
+\\fnotecite[pre]{fnotecite:2022}
+
+Natbib compatibility commands:
+\\citet{citet:2022}
+\\citet*[pre][pos]{citet*:2022}
+\\citep[pre][pos]{citep:2022}
+\\citep*[pos]{citep*:2022}
+\\citealt[pre][]{citealt:2022}
+\\citealt*[][]{citealt*:2022}
+\\citealp[pre][pos]{citealp:2022}
+\\citealp*{citealp*:2022}
+\\Citet[pre][pos]{Citet:2022}
+\\Citet*[pre][pos]{Citet*:2022}
+\\Citep[pre][pos]{Citep:2022}
+\\Citep*[pre][pos]{Citep*:2022}
+
+Test for bug#56655:
+There was a few \\% of increase in budget \\Citep*{bug:56655}.
+
+And this should be % \\cite{ignored}.
+\\end{document}")
+ (write-region (point-min) (point-max) tex-file))
+ (find-file tex-file)
+ (setq keys (reftex-all-used-citation-keys))
+ (should (equal (sort keys #'string<)
+ (sort '(;; Standard commands:
+ "cite:2022" "Cite:2022"
+ "parencite:2022" "Parencite:2022"
+ "footcite:2022" "footcitetext:2022"
+ ;; Style specific commands:
+ "textcite:2022" "Textcite:2022"
+ "smartcite:2022" "Smartcite:2022"
+ "cite*:2022" "parencite*:2022"
+ ;; Style independent commands:
+ "autocite:2022" "autocite*:2022"
+ "Autocite:2022" "Autocite*:2022"
+ ;; Text commands
+ "citeauthor:2022" "citeauthor*:2022"
+ "Citeauthor:2022" "Citeauthor*:2022"
+ "citetitle:2022" "citetitle*:2022"
+ "citeyear:2022" "citeyear*:2022"
+ "citedate:2022" "citedate*:2022"
+ "citeurl:2022"
+ ;; Special commands:
+ "nocite:2022" "fullcite:2022"
+ "fullfootcite:2022"
+ "volcite:2022" "Volcite:2022"
+ "pvolcite:2022" "Pvolcite:2022"
+ "fvolcite:2022" "ftvolcite:2022"
+ "svolcite:2022" "Svolcite:2022"
+ "tvolcite:2022" "Tvolcite:2022"
+ "avolcite:2022" "Avolcite:2022"
+ "Notecite:2022" "pnotecite:2022"
+ "Pnotecite:2022" "fnotecite:2022"
+ ;; Natbib compatibility commands:
+ "citet:2022" "citet*:2022"
+ "citep:2022" "citep*:2022"
+ "citealt:2022" "citealt*:2022"
+ "citealp:2022" "citealp*:2022"
+ "Citet:2022" "Citet*:2022"
+ "Citep:2022" "Citep*:2022"
+ "bug:56655")
+ #'string<)))
+ (kill-buffer (file-name-nondirectory tex-file)))))
+
+(ert-deftest reftex-renumber-simple-labels ()
+ "Test `reftex-renumber-simple-labels'.
+The function must recognize labels defined with macros like
+\\label and the ones as key=value option in optional or mandatory
+argument of other macros or environments."
+ (ert-with-temp-directory temp-dir
+ (let ((tex-file (expand-file-name "renumber.tex" temp-dir)))
+ (with-temp-buffer
+ (insert "\
+\\documentclass{article}
+\\usepackage{tcolorbox}
+\\tcbuselibrary{theorems}
+\\usepackage{fancyvrb}
+\\usepackage{listings}
+
+\\begin{document}
+
+This is with tcolorbox package:
+\\begin{problem}[%
+ colback = white ,
+ colframe = red!50!black ,
+ fonttitle = \\bfseries ,
+ description delimiters = {\\flqq}{\\frqq} ,
+ label = {problem:2}]{Prove RH2}{}
+ Problem
+\\end{problem}
+
+This is with vanilla \\LaTeX:
+\\begin{equation}
+ \\label{eq:2}
+ 2
+\\end{equation}
+By \\eqref{eq:2} and \\ref{problem:2}
+
+This is with tcolorbox package:
+\\begin{problem}[%
+ colback=white,
+ colframe=red!50!black,
+ fonttitle=\\bfseries,
+ theorem label supplement={hypertarget={XYZ-##1}},
+ theorem full label supplement={code={\\marginnote{##1}}},
+ label={problem:1}]{Prove RH1}{}
+ Problem
+\\end{problem}
+
+This is with vanilla \\LaTeX:
+\\begin{equation}
+ \\label{eq:1}
+ 1
+\\end{equation}
+
+\\Cref{problem:1} and \\pageref{eq:1}.
+
+\\begin{problem}[label={problem:6}]{Some Problem}{}
+ Problem
+\\end{problem}
+
+\\Ref{problem:6}.
+
+This is with fancyvrb package:
+\\begin{Verbatim}[reflabel={lst:6}]
+Some Verb Content
+\\end{Verbatim}
+
+\\pageref{lst:6}
+
+This is with listings package:
+\\begin{lstlisting}[language=elisp,caption=Some Caption,label={lst:3}]
+(car (cons 1 '(2)))
+\\end{lstlisting}
+
+\\ref{lst:3}
+
+\\end{document}")
+ (write-region (point-min) (point-max) tex-file))
+ ;; The label prefix must be known to RefTeX:
+ (add-to-list 'reftex-label-alist
+ '("problem" ?p "problem:" "~\\ref{%s}"
+ nil nil nil)
+ t)
+ (add-to-list 'reftex-label-alist
+ '("Verbatim" ?l "lst:" "~\\ref{%s}"
+ nil nil nil)
+ t)
+ ;; The environments must be known to RefTeX otherwise the labels
+ ;; aren't parsed correctly:
+ (add-to-list 'reftex-label-regexps
+ (concat "\\\\begin{\\(?:problem\\|Verbatim\\)}"
+ "\\[[^][]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*}[^}{]*\\)*"
+ "}[^}{]*\\)*"
+ "}[^][]*\\)*"
+ "\\<\\(?:ref\\)?label[[:space:]]*=[[:space:]]*"
+ "{?\\(?1:[^] ,}\r\n\t%]+\\)"
+ "[^]]*\\]")
+ t)
+ ;; Always run this after changing `reftex-label-regexps':
+ (reftex-compile-variables)
+ (find-file tex-file)
+ ;; Silence the user query:
+ (cl-letf (((symbol-function 'yes-or-no-p) #'always))
+ (reftex-renumber-simple-labels))
+ (should (string= (buffer-string)
+ "\
+\\documentclass{article}
+\\usepackage{tcolorbox}
+\\tcbuselibrary{theorems}
+\\usepackage{fancyvrb}
+\\usepackage{listings}
+
+\\begin{document}
+
+This is with tcolorbox package:
+\\begin{problem}[%
+ colback = white ,
+ colframe = red!50!black ,
+ fonttitle = \\bfseries ,
+ description delimiters = {\\flqq}{\\frqq} ,
+ label = {problem:1}]{Prove RH2}{}
+ Problem
+\\end{problem}
+
+This is with vanilla \\LaTeX:
+\\begin{equation}
+ \\label{eq:1}
+ 2
+\\end{equation}
+By \\eqref{eq:1} and \\ref{problem:1}
+
+This is with tcolorbox package:
+\\begin{problem}[%
+ colback=white,
+ colframe=red!50!black,
+ fonttitle=\\bfseries,
+ theorem label supplement={hypertarget={XYZ-##1}},
+ theorem full label supplement={code={\\marginnote{##1}}},
+ label={problem:2}]{Prove RH1}{}
+ Problem
+\\end{problem}
+
+This is with vanilla \\LaTeX:
+\\begin{equation}
+ \\label{eq:2}
+ 1
+\\end{equation}
+
+\\Cref{problem:2} and \\pageref{eq:2}.
+
+\\begin{problem}[label={problem:3}]{Some Problem}{}
+ Problem
+\\end{problem}
+
+\\Ref{problem:3}.
+
+This is with fancyvrb package:
+\\begin{Verbatim}[reflabel={lst:1}]
+Some Verb Content
+\\end{Verbatim}
+
+\\pageref{lst:1}
+
+This is with listings package:
+\\begin{lstlisting}[language=elisp,caption=Some Caption,label={lst:2}]
+(car (cons 1 '(2)))
+\\end{lstlisting}
+
+\\ref{lst:2}
+
+\\end{document}"))
+ (kill-buffer (file-name-nondirectory tex-file)))))
;;; Autoload tests
diff --git a/test/lisp/textmodes/texinfo-resources/fill.erts b/test/lisp/textmodes/texinfo-resources/fill.erts
new file mode 100644
index 00000000000..95f3b09eba8
--- /dev/null
+++ b/test/lisp/textmodes/texinfo-resources/fill.erts
@@ -0,0 +1,70 @@
+Code:
+ (lambda ()
+ (texinfo-mode)
+ (fill-paragraph))
+
+Name: fill1
+Point-Char: |
+
+=-=
+@noindent Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+=-=
+@noindent Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+=-=-=
+
+Name: fill2
+Point-Char: |
+
+=-=
+@cindex relative| remapping, faces
+@cindex base remapping, faces
+ The following functions implement a higher-level interface to @code{face-remapping-alist}.
+=-=-=
+
+
+Name: fill3
+Point-Char: |
+
+=-=
+@cindex relative remapping, faces
+@cindex base remapping, faces|
+ The following functions implement a higher-level interface to @code{face-remapping-alist}.
+=-=-=
+
+Name: fill4
+Point-Char: |
+
+=-=
+@cindex relative remapping, faces
+@cindex base remapping, faces
+ The following functions| implement a higher-level interface to @code{face-remapping-alist}.
+=-=
+@cindex relative remapping, faces
+@cindex base remapping, faces
+ The following functions| implement a higher-level interface to
+@code{face-remapping-alist}.
+=-=-=
+
+Name: fill5
+Point-Char: |
+
+=-=
+@defun face-remap-add-relative face &rest specs
+|This function adds the face spec in @var{specs} as relative
+remappings for face @var{face} in the current buffer. The remaining
+arguments, @var{specs}, should form either a list of face names, or a
+property list of attribute/value pairs.
+=-=
+@defun face-remap-add-relative face &rest specs
+This function adds the face spec in @var{specs} as relative remappings
+for face @var{face} in the current buffer. The remaining arguments,
+@var{specs}, should form either a list of face names, or a property
+list of attribute/value pairs.
+=-=-=
+
+Name: fill6
+
+=-=
+@subsection This is a very very very very very very very very very very long subsection name
+=-=-=
diff --git a/test/lisp/textmodes/texinfo-tests.el b/test/lisp/textmodes/texinfo-tests.el
new file mode 100644
index 00000000000..48cc5fece2c
--- /dev/null
+++ b/test/lisp/textmodes/texinfo-tests.el
@@ -0,0 +1,33 @@
+;;; texinfo-tests.el --- Tests for texinfo.el -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'texinfo)
+(require 'ert)
+(require 'ert-x)
+
+(ert-deftest test-filling ()
+ (ert-test-erts-file (ert-resource-file "fill.erts")))
+
+;;; texinfo-tests.el ends here