-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix whitespace sensitive testing for aligned multi-line strings #37
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crisptrutski
changed the title
Fix whitespace sensitive testing for aligned multi-line strings.
Fix whitespace sensitive testing for aligned multi-line strings
May 23, 2024
crisptrutski
commented
May 23, 2024
tables (into {} (for [t (:tables comps) | ||
i (:instances (:component t))] | ||
[i (:component t)])) | ||
columns (index-by-instances (:columns comps)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't resist sneaking this in as well 🧼
tsmacdonald
reviewed
May 23, 2024
tsmacdonald
reviewed
May 23, 2024
tsmacdonald
reviewed
May 23, 2024
tsmacdonald
approved these changes
May 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stand by my statements, but am giving you a ✔️ since I trust you to do them without supervision, haha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfortunately when you visually align multi-line strings in Clojure, you will accumulate an additional margin due to the current indentation level:
Things get worse if you want to define before and after strings with different indentations:
Our workaround for this was to collapse contiguous whitespace, but in that case we could have false negatives where we don't detect whitespace being mangled.
This change brings in a method that strips the common indentation from the extra lines, so that the alignment in the actual strings can match how it looks in one's code, emulating the way that multi-line strings are defined in modern languages like Rust.
It also introduces the
ws=
macro, which strips the common indentation from all string literals within the given form before performing an equality check. This gives great ergonomics for whitespace-sensitive tests. This is a better solution thantest-replacements
as well, which prevented one from evaluating the inner replacement result form.