From c858b5740ccf610b5e1c7bf72946f30a6bcdc4db Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Fri, 7 Jun 2024 07:40:20 +0300 Subject: [PATCH] tests: test actual indentation instead of internal calculations This commits adds testing of the actual `pcal-mode-indent-line` and `tla-mode-indent-line` functions, rather than some internal getters. As a bonus, this allows us to print the actual line in the tests for the case something fails, which we do as well. --- test/tla-pcal-mode-test.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/tla-pcal-mode-test.el b/test/tla-pcal-mode-test.el index 580cc88..684b512 100644 --- a/test/tla-pcal-mode-test.el +++ b/test/tla-pcal-mode-test.el @@ -53,8 +53,8 @@ ;; in the test file (let ((lines (read-lines (test-file-path (concat test-name "." mode)))) (indent-func (if (equal mode "pcal") - #'pcal-mode--indent-column - #'tla-mode--indent-column))) + #'pcal-mode-indent-line + #'tla-mode-indent-line))) (run-indent-test lines indent-func))) (ert-deftest pcal-mode--indent-column-test () (indent-test "indent-columns" "pcal")) @@ -77,11 +77,15 @@ (pcal-mode-indent-offset 2) (indent-tabs-mode nil)) (delete-horizontal-space) - (let* ((actual-indent (funcall indent-func)) - (exp-line (elt lines n))) + (funcall indent-func) + (let ((actual-indent (current-indentation)) + (exp-line (elt lines n)) + (actual-line (buffer-substring-no-properties + (line-beginning-position) + (line-end-position)))) ;; Add enough extra data to make clear where the failure happened (should (equal (list expected-indent (list 'line n) exp-line) - (list actual-indent (list 'line n) exp-line)))))))) + (list actual-indent (list 'line n) actual-line)))))))) (ert-deftest tla-mode--keep-conjucts-indented () (let ((test-lines