-
-
Notifications
You must be signed in to change notification settings - Fork 438
Add test case for multiline string #610
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
Merged
weaverryan
merged 2 commits into
symfony:master
from
jon-ht:failing-multiline-string-test-case
May 29, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| === | ||
| $data['nelmio_api_doc']['documentation']['info']['description'] = "Multiline string\nSecond line\nThird line"; | ||
| === | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| Third line | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beautiful test cases |
||
18 changes: 18 additions & 0 deletions
18
tests/Util/yaml_fixtures/multiline_string_before_property.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| foo: bar | ||
| === | ||
| $data['nelmio_api_doc']['documentation']['info']['description'] = "Multiline string\nSecond line\nThird line\n"; | ||
| === | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| Third line | ||
| foo: bar |
18 changes: 18 additions & 0 deletions
18
tests/Util/yaml_fixtures/multiline_string_remove_line.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| Third line | ||
| foo: bar | ||
| === | ||
| $data['nelmio_api_doc']['documentation']['info']['description'] = "Multiline string\nSecond line\n"; | ||
| === | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| foo: bar |
20 changes: 20 additions & 0 deletions
20
tests/Util/yaml_fixtures/multiline_string_with_blank_line.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
|
|
||
| Second line | ||
| foo: bar | ||
| === | ||
| $data['nelmio_api_doc']['documentation']['info']['description'] = "Multiline string\n\nSecond line\nThird line\n"; | ||
| === | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
|
|
||
| Second line | ||
| Third line | ||
| foo: bar |
15 changes: 15 additions & 0 deletions
15
tests/Util/yaml_fixtures/multiline_string_without_update.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line | ||
| === | ||
|
|
||
| === | ||
| nelmio_api_doc: | ||
| documentation: | ||
| info: | ||
| description: | | ||
| Multiline string | ||
| Second line |
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.
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.
Why do we need to
rtrim()here? I can see that if I remove it the tests fail, but I can't figure out why it's needed.Uh oh!
There was an error while loading. Please reload this page.
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.
One thing I noticed is, in this test case multiline_string_before_property.test,
$valueends with an\nThis will cause
indentMultilineYamlArrayto add an extra line that's not wanted.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.
Ah, I understand. I think the implementation is what's confusing me. All multiline arrays must end in a line break, by their very nature. If anything, in this spot, (just thinking about the logical flow of the code) I would expect you to be guaranteeing that the
$newYamlValuedoes end in\n, instead of stripping it. After all, if we made sure that$newYamlValueended in 1 line break... then that should work perfectly with YAML, which also wants the line break :). I'm wondering if we're trimming and adding\nin so many places that we're doing and undoing extra work.There is the edge-case of not needing the "\n" if the multiline string is at the end of the file. That should be handled (somewhere) with an
ifstatement specifically for it. Something like: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 won't lie to you, I also think there is a lot of trimming to handle multiline string...
Actually, it seems that re-adding original \n (after
$newYamlValue = "\n".$this->indentMultilineYamlArray($newYamlValue);) breaks test case because, as mentionned above, YamlDumper will add an extra lineMaybe this bug is related to Yaml component and not
YamlSourceManipulator