Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage&prints by actually checking indentation #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Hi-Angel
Copy link
Contributor

@Hi-Angel Hi-Angel commented Jun 7, 2024

The older code didn't test the public indentation function but instead some getter that the function was using. It also had a minor bug where the ELT's should function was given exp-line as part of the "actual" parameter.

We fix both problems and also do some minor cleanup.


This PR also includes a commit that changes tla-mode-indent-line to have code similar to commit fc1af6d for the other indentation function. When I did fc1af6d I didn't know there are two functions for the same functional. Feel free to ask me to send it as a separate PR if you want.

@Hi-Angel
Copy link
Contributor Author

Hi-Angel commented Jun 7, 2024

UPD: fixed commit description

There's terminology clash: `pcal-mode--statement-end-re` just detects
anything ending with semicolon, however the
`pcal-mode--statement-begin-re` detects variables specifically. One of
them seem to be named incorrectly, let's rename the `statement-begin`
to `variables-begin`.
tabs indentation is up to Emacs' indent functions, we don't need to
test it. Avoiding tabs in tests simplifies comparing the current
indentation and allows to increase test coverage in the next commit.
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.
This is similar to

     fc1af6d "Let `indent-line-to` decide on (point) location"

It turns out there's two indenation functions, so fix the 2nd one as well.

This unbreaks (newline-and-indent).

Before this commit calling newline-and-indent would put caret at the
beginning of line. This is not what a user wants, because they usually
desire continue typing code on the new line.

So remove the save-excursion call.

While at it, remove the beginning-of-line call as well, because both
are called first thing inside (pcal-mode--indent-column), so as far as
that function concerned having them earlier is unnecessary.
@Hi-Angel
Copy link
Contributor Author

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant