branch: elpa/julia-mode commit addd3d461b21d83da13331b96f198e908cd9b95e Merge: b194039 7102542 Author: Tamas K. Papp <tkp...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #81 from JuliaEditorSupport/tp/add-substitution-tests Add unit tests for LaTeX substitution. --- julia-mode-tests.el | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/julia-mode-tests.el b/julia-mode-tests.el index f5436c7..cc41fcb 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -515,7 +515,7 @@ y*y" 'beginning-of-defun "y\\*y" 1 nil 2)) "macro current_module() return VERSION >= v\"0.7-\" :(@__MODULE__) : :(current_module()))) end" 'beginning-of-defun "@" 1)) - + (ert-deftest julia--test-beginning-of-defun-1 () "Point moves to beginning of defun in 'function's." (julia--should-move-point @@ -595,6 +595,32 @@ end return fact(x) end" 'end-of-defun "n == 0" "return fact(x)[ \n]+end" 'end 2)) +;;; +;;; substitution tests +;;; + +(defun julia--substitute (contents position) + "Call LaTeX subsitution in a buffer with `contents' at point +`position', and return the resulting buffer." + (with-temp-buffer + (julia-mode) + (insert contents) + (goto-char position) + (julia-latexsub) + (buffer-string))) + +(ert-deftest julia--test-substitutions () + (should (equal (julia--substitute "\\alpha " 7) "α ")) + (should (equal (julia--substitute "x\\alpha " 8) "xα ")) + (should (equal (julia--substitute "\\kappa\\alpha(" 13) "\\kappaα(")) + (should (equal (julia--substitute "\\alpha" 7) "α")) + ; (should (equal (julia--substitute "\\alpha" 6) "α")) ; BROKEN + ) + +;;; +;;; run all tests +;;; + (defun julia--run-tests () (interactive) (if (featurep 'ert)