[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex dda4932 14/17: Add new fontificat
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex dda4932 14/17: Add new fontification test |
Date: |
Fri, 2 Apr 2021 04:13:20 -0400 (EDT) |
branch: externals/auctex
commit dda49328337a847629e615d483d7b712bea85016
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Add new fontification test
* tests/latex/font-latex-test.el
(font-latex-general-fontification): Add test for general
fontification of vanilla LaTeX files.
---
tests/latex/font-latex-test.el | 178 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 178 insertions(+)
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
index 5e5fccf..577ec77 100644
--- a/tests/latex/font-latex-test.el
+++ b/tests/latex/font-latex-test.el
@@ -83,4 +83,182 @@ $a$")
(should (font-latex-extend-region-backwards-quotation))
(should (= font-lock-beg 5)))))
+(ert-deftest font-latex-general-fontification ()
+ "Test general fontification in a LaTeX file."
+ (with-temp-buffer
+ (let ((TeX-install-font-lock 'font-latex-setup)
+ (font-latex-fontify-sectioning 'color))
+ (insert "\
+\\documentclass[10pt]{article}
+\\begin{document}
+\\section{Macros}
+Inline verbatim test: \\verb|x|
+Inline math test: $x$, \\(x\\)
+Marginpar test: \\marginpar{x}
+Sedate macro test: \\sedate
+\\section{Font Specifiers}
+Roman face test: \\textrm{x}
+Bold face test: \\textbf{x}
+Italic face test: \\textit{x}
+Bold italic face test: \\textit{\\textbf{x}}
+Emphasize face test: \\emph{x}
+Declarations test: \\ttfamily x {\\ttfamily x}
+ \\itshape x {\\itshape x}
+ \\bfseries x {\\bfseries x}
+\\section{Environments}
+\\subsection{Math}
+\\begin{math}
+ x
+\\end{math}
+\\[
+ x
+\\]
+\\[x\\]
+\\begin{displaymath}
+ x
+\\end{displaymath}
+\\begin{equation}
+ x
+\\end{equation}
+\\subsection{Misc.}
+\\begin{verbatim}
+x
+\\end{verbatim}
+\\begin{description}
+\\item[x] x
+\\end{description}
+\\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:\n")
+ (LaTeX-mode)
+ (font-lock-ensure)
+ (goto-char (point-min))
+
+ ;; Test for \documentclass:
+ (search-forward-regexp "\\\\document\\(?1:c\\)lass\\[")
+ (should (font-latex-faces-present-p 'font-lock-keyword-face
+ (match-beginning 1)))
+ (forward-char)
+ ;; Optional argument
+ (should (font-latex-faces-present-p 'font-lock-variable-name-face))
+ (search-forward "{")
+ (forward-char)
+ ;; Mandatory argument:
+ (should (font-latex-faces-present-p 'font-lock-function-name-face))
+ (end-of-line)
+
+ ;; Test for \section macro itself:
+ (search-forward-regexp "\\\\sec\\(?1:t\\)ion{")
+ (should (font-latex-faces-present-p 'font-lock-keyword-face
+ (match-beginning 1)))
+ (goto-char (match-end 0))
+ (forward-char)
+ ;; Test for the argument of \section:
+ (should (font-latex-faces-present-p 'font-lock-type-face))
+ (end-of-line)
+
+ ;; Test for inline verb:
+ (search-forward "\\verb|")
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (end-of-line)
+
+ ;; Test for inline math:
+ (search-forward "$")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+ (search-forward "\\(")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+ (end-of-line)
+
+ ;; Test for marginpar:
+ (search-forward "\\marginpar{")
+ (should (font-latex-faces-present-p 'font-lock-constant-face))
+ (end-of-line)
+
+ ;; Test for unfontified macro:
+ (search-forward "\\seda")
+ (should (font-latex-faces-present-p 'font-latex-sedate-face))
+ (end-of-line)
+
+ ;; Test for font specifiers:
+ (search-forward "\\textrm{")
+ (should (font-latex-faces-present-p 'font-lock-type-face))
+ (end-of-line)
+ (search-forward "\\textbf{")
+ (should (font-latex-faces-present-p 'font-latex-bold-face))
+ (end-of-line)
+ (search-forward "\\textit{")
+ (should (font-latex-faces-present-p 'font-latex-italic-face))
+ (end-of-line)
+ (search-forward "\\textit{\\textbf{")
+ (should (font-latex-faces-present-p '(font-latex-italic-face
+ font-latex-bold-face)))
+ (end-of-line)
+ (search-forward "\\emph{")
+ (should (font-latex-faces-present-p 'font-latex-italic-face))
+ (end-of-line)
+ (search-forward "\\ttfam")
+ (should (font-latex-faces-present-p 'font-lock-type-face))
+ (search-forward "\\ttfamily ")
+ (should (font-latex-faces-present-p 'font-lock-type-face))
+ (end-of-line)
+ (search-forward "\\itsha")
+ (should (font-latex-faces-present-p 'font-latex-italic-face))
+ (search-forward "\\itshape ")
+ (should (font-latex-faces-present-p 'font-latex-italic-face))
+ (end-of-line)
+ (search-forward "\\bfseri")
+ (should (font-latex-faces-present-p 'font-latex-bold-face))
+ (search-forward "\\bfseries ")
+ (should (font-latex-faces-present-p 'font-latex-bold-face))
+ (end-of-line)
+
+ ;; Test for math environments:
+ (search-forward-regexp "\\\\be\\(?1:g\\)in{ma\\(?2:t\\)h}")
+ (should (font-latex-faces-present-p 'font-lock-keyword-face
+ (match-beginning 1)))
+ (should (font-latex-faces-present-p 'font-lock-function-name-face
+ (match-beginning 2)))
+ (forward-line)
+ (skip-chars-forward "[:blank:]")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+ (LaTeX-find-matching-end)
+
+ (search-forward "\\[")
+ (forward-line)
+ (skip-chars-forward "[:blank:]")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+
+ (search-forward "\\[")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+ (end-of-line)
+
+ (search-forward "\\begin{displaymath}")
+ (forward-line)
+ (skip-chars-forward "[:blank:]")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+ (LaTeX-find-matching-end)
+
+ (search-forward "\\begin{equation}")
+ (forward-line)
+ (skip-chars-forward "[:blank:]")
+ (should (font-latex-faces-present-p 'font-latex-math-face))
+ (LaTeX-find-matching-end)
+
+ ;; Test for misc. environments:
+ (search-forward "\\begin{verbatim}")
+ (forward-line)
+ (should (font-latex-faces-present-p 'font-latex-verbatim-face))
+ (LaTeX-find-matching-end)
+
+ ;; Check the fontification of \item macro itself:
+ (search-forward-regexp "\\\\it\\(?1:e\\)m\\[")
+ (should (font-latex-faces-present-p 'font-lock-keyword-face
+ (match-beginning 1)))
+ ;; Now for the optional argument:
+ (should (font-latex-faces-present-p 'font-lock-variable-name-face))
+ (LaTeX-find-matching-end) )))
+
;;; font-latex-test.el ends here
- [AUCTeX-diffs] [elpa] externals/auctex 896346a 01/17: Fix preview-latex and regression tests, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 896346a 01/17: Fix preview-latex and regression tests, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 70029e0 02/17: Fix preamble cache, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 0ce30c1 03/17: * tests/japanese/preview-latex.el: Make cleanup forms more robust, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 404aea2 11/17: Fix broken test, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 36369f6 05/17: Reduce byte compiler warning, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 91ac45a 07/17: Reduce byte compiler warning, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 7049512 04/17: Reduce byte compiler warning, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 5d73084 12/17: Some minor followups, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex c2a40eb 13/17: Use built-in functions for similar functions, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex b2383d5 15/17: Remove xemacs compat elements, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex dda4932 14/17: Add new fontification test,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex c35f0d1 06/17: Use #' instead of ' to quote function where possible, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 5696f07 08/17: Reduce byte compiler warning, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex a83033a 10/17: Fix doc string, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex ab161ba 09/17: ; Convert tabs to spaces, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex d1047f3 17/17: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2021/04/02
- [AUCTeX-diffs] [elpa] externals/auctex 3750d1a 16/17: Resolve unnecassary back quote, Tassilo Horn, 2021/04/02