Open
Conversation
This file contains hidden or 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
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.
rubyfmtis almost entirely tested with fixtures. This is mostly fine, but there's a few isolated bits of logic that could use some unit testing. String escaping is the most obvious one -- it's bytes in to bytes out and has quite specific rules that are easy to test in isolation. (Heredocs and some of the comment bits also could use them, but strings are probably the highest value for now.)This does add one
elsebranch to the actual production code purely as a defense mechanism/future-proof that I saw in unit tests, but I'm fairly confident it's never reachable in real Ruby code (see theword_array_trailing_backslash_preservedtest). It covers a trailing slash in a%warray, which in real usages (%w[\]) would escape the closing delimiter and be invalid, so thatelseis unreachable, but as far asescape_word_array_contentis concerned it does the right thing if it ever were to get in that state.