[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Test for fontification
From: |
Arash Esbati |
Subject: |
Test for fontification |
Date: |
Tue, 30 Mar 2021 22:55:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 |
Hi all,
I think we should have a test suite for general fontification of latex
file. Adding such a test isn't complicated:
--8<---------------cut here---------------start------------->8---
diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
index 5e5fccf0..4482a9bc 100644
--- a/tests/latex/font-latex-test.el
+++ b/tests/latex/font-latex-test.el
@@ -83,4 +83,41 @@ $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))
+ (LaTeX-mode)
+ (insert "\
+\\documentclass{article}
+\\begin{document}
+Inline verbatim test: \\verb|x|
+Inline math test: $x$
+Marginpar test: \\marginpar{x}
+\\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:\n")
+ (font-lock-ensure)
+ (goto-char (point-min))
+ ;; Test for inline verb:
+ (search-forward-regexp "\\\\verb|")
+ (should (eq 'font-latex-verbatim-face
+ (get-text-property (match-end 0) 'face)))
+ (end-of-line)
+
+ ;; Test for inline math:
+ (search-forward-regexp (regexp-quote "$"))
+ (should (eq 'font-latex-math-face
+ (get-text-property (match-end 0) 'face)))
+ (end-of-line)
+
+ ;; Test for marginpar:
+ (search-forward-regexp (regexp-quote "\\marginpar{"))
+ (should (memq 'font-lock-constant-face
+ (get-text-property (match-end 0) 'face)))
+ (end-of-line) )))
+
;;; font-latex-test.el ends here
--8<---------------cut here---------------end--------------->8---
What do others think, do we need such a general test? And if yes, which
cases should be included?
Any comments welcome. Best, Arash
- Test for fontification,
Arash Esbati <=