Hi Mosè, Mosè Giordano <m...@gnu.org> writes:
> 2016-12-14 15:52 GMT+01:00 Arash Esbati <arash.esbati...@gmail.com>: >> >> Mosè Giordano <m...@gnu.org> writes: >> Thanks for testing! I can take the file I posted with some other >> environments and add it as `tabular-ampersand-count.tex' under >> auctex.git/tests/latex. Is this what you have in mind? > > Yes. But if you prefer, you may want to create a new file for testing > these tabular-related features, > >> I can't see how >> to insert the test into `latex-test.el'. Any hints? > > For example in the file you sent at the beginning of the thread > > (LaTeX-array-count-columns 1920 1928) > > returns currently 0, but 4 after evaluating your new definition of the > function. In the test file you can add a test like this one. Thanks for your response. I did the following: I added this to `latex-test.el': --8<---------------cut here---------------start------------->8--- diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el index cc23caf..ac2ea36 100644 --- a/tests/latex/latex-test.el +++ b/tests/latex/latex-test.el @@ -1,6 +1,6 @@ ;;; latex-test.el --- tests for LaTeX mode -;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. +;; Copyright (C) 2014--2016 Free Software Foundation, Inc. ;; This file is part of AUCTeX. @@ -48,7 +48,11 @@ line and from another directory." 'LaTeX-math-indent/in "math-indent-in.tex" 'LaTeX-math-indent/out - "math-indent-out.tex") + "math-indent-out.tex" + 'tabular-count-ampersands/in + "tabular-count-ampersands-in.tex" + 'tabular-count-ampersands/out + "tabular-count-ampersands-out.tex") (ert-deftest LaTeX-indent-tabular () (should (string= @@ -106,4 +110,22 @@ line and from another directory." (LaTeX-insert-environment "foobar") (buffer-string))))) +;; Test for inserting &'s with `M-RET' in various tabular environment. +;; One thing missing is running style hooks while running the test. +(ert-deftest LaTeX-count-ampersands-inserted-in-tabular () + (should (string= + (with-temp-buffer + (insert-file-contents tabular-count-ampersands/in) + (LaTeX-mode) + ;; Do not ask for opt. argument in (TeX-insert-macro "\\"): + (let ((TeX-insert-macro-default-style 'mandatory-args-only)) + (goto-char (point-min)) + (while (search-forward "LaTeX-insert-item" nil t) + (LaTeX-insert-item))) + (buffer-string)) + (with-temp-buffer + (insert-file-contents tabular-count-ampersands/out) + (LaTeX-mode) + (buffer-string))))) + ;;; latex-test.el ends here --8<---------------cut here---------------end--------------->8--- I made 2 files `tabular-count-ampersands-in.tex' --8<---------------cut here---------------start------------->8--- \documentclass{article} % \usepackage{tabularx,tabulary,longtable} \begin{document} Standard LaTeX tabular: \begin{tabular}[t]{llll} 1 & 2 & 3 & LaTeX-insert-item \end{tabular} \begin{tabular}[t]{*{3}{l}r} 1 & 2 & 3 & LaTeX-insert-item \end{tabular} \begin{tabular}{*{3}{l}>{\tiny\hfill}l<{\hfill}} 1 & 2 & 3 & LaTeX-insert-item \end{tabular} \begin{tabular*}{1.0\linewidth}[t]{@{}lllr@{}} 1 & 2 & 3 & LaTeX-insert-item \end{tabular*} \begin{tabular*}{1.0\linewidth}[t]{@{}*{3}{|l}|r|} 1 & 2 & 3 & LaTeX-insert-item \end{tabular*} \end{document} --8<---------------cut here---------------end--------------->8--- and `tabular-count-ampersands-out.tex' --8<---------------cut here---------------start------------->8--- \documentclass{article} % \usepackage{tabularx,tabulary,longtable} \begin{document} Standard LaTeX tabular: \begin{tabular}[t]{llll} 1 & 2 & 3 & LaTeX-insert-item \\ &&& \end{tabular} \begin{tabular}[t]{*{3}{l}r} 1 & 2 & 3 & LaTeX-insert-item \\ &&& \end{tabular} \begin{tabular}{*{3}{l}>{\tiny\hfill}l<{\hfill}} 1 & 2 & 3 & LaTeX-insert-item \\ &&& \end{tabular} \begin{tabular*}{1.0\linewidth}[t]{@{}lllr@{}} 1 & 2 & 3 & LaTeX-insert-item \\ &&& \end{tabular*} \begin{tabular*}{1.0\linewidth}[t]{@{}*{3}{|l}|r|} 1 & 2 & 3 & LaTeX-insert-item \\ &&& \end{tabular*} \end{document} --8<---------------cut here---------------end--------------->8--- It works. Do you have a hint how I can run style hooks (e.g. tabularx.el) while running the test? I could expand the test for the packages being commented out right now. Best, Arash _______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel