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

First Pass at Multiline Strings #43

Merged
merged 16 commits into from May 16, 2022
Merged

First Pass at Multiline Strings #43

merged 16 commits into from May 16, 2022

Conversation

floralvikings
Copy link
Contributor

My attempt at implementing multi-line strings

This is still in a fairly rough state:

  • Only "folded" (using >) strings are implemented
  • Code could use some review and possibly some cleanup

However, if this approach is acceptable, I can add support and an equivalent set of tests for "literal" (using |) strings as well.

Please let me know if there are test cases I'm missing! Multiline strings in YAML are way more complicated than I initially realized so I'm sure there's something I haven't thought of.

@Him188 Him188 self-requested a review May 14, 2022 17:45
Also fix a bug I found thanks to a mistake in a test. Still looking for
more test cases to throw at it to make sure it works as expected in all
scenarios
@floralvikings
Copy link
Contributor Author

I went ahead and added tests and support for literal style strings; even if the implementation isn't up to snuff, the tests should still be useful

@floralvikings floralvikings marked this pull request as ready for review May 15, 2022 01:55
Copy link
Owner

@Him188 Him188 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, thanks for the excellent work!

Do takeLinesForMultilineFoldedString and takeLinesForMultilineLiteralString differ only in the takeLineForMultlineLiteralString and takeLineForMultlineFoldedString they call? If so they can be combined with a lambda parameter to reduce duplication.

Also takeMultilineLiteralString and takeMultilineFoldedString looks similar, too. If there is some reasoning not generalizing them is a better choice, please note it in the source.

Code logic looks good. And I see from the tests that they are comprehensive enough at least for now. We can't figure out what are missing until we use the test suite (#24)


@BeforeTest
fun createSerializers() {
testStringDataSerializer = DecoderTest.TestStringData.serializer()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to declare your own TestData class in this test. So DecoderTest can be changed in the future without any concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah good call, done in 531d708

@floralvikings
Copy link
Contributor Author

@Him188 I've updated the PR in 7f017cf, I've extracted some duplicate code into functions where possible and left comments detailing the differences between the functions that couldn't be easily combined

@Him188 Him188 added the enhancement New feature or request label May 16, 2022
@Him188 Him188 merged commit 23f81a6 into Him188:master May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants