Skip to content

Commit

Permalink
tests: test actual indentation instead of internal calculations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hi-Angel committed Jun 7, 2024
1 parent ff2b0ba commit c858b57
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/tla-pcal-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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
Expand Down

0 comments on commit c858b57

Please sign in to comment.