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

Output document end marker after open ended scalars #162

Merged
merged 1 commit into from
Mar 28, 2020

Conversation

perlpunk
Copy link
Member

@perlpunk perlpunk commented Dec 27, 2019

See also #123

Depends on: #160

This will output ... at the end of the YAML Stream if the previous scalar is open ended, e.g. a block scalar |+ with trailing empty lines.

Tests passing:
blacklist/libyaml-emitter

  • F8F9: Spec Example 8.5. Chomping Trailing Lines
  • K858: Spec Example 8.6. Empty Scalar Chomping

Unfortunately there is no possibility to edit the list of skipped tests in this PR, so I have to keep this in mind and adjust the skiplist later.

@perlpunk perlpunk force-pushed the perlpunk/open-ended branch from cdfadff to 2bb1265 Compare March 23, 2020 16:34
@perlpunk perlpunk force-pushed the perlpunk/open-ended branch from 2bb1265 to cc0d439 Compare March 26, 2020 21:33
@perlpunk perlpunk changed the base branch from master to release/0.2.3 March 26, 2020 21:33
@perlpunk perlpunk marked this pull request as ready for review March 28, 2020 17:02
@perlpunk perlpunk merged commit fa1293a into release/0.2.3 Mar 28, 2020
@perlpunk perlpunk changed the title WIP Output document end marker after open ended scalars Output document end marker after open ended scalars Mar 29, 2020
@perlpunk
Copy link
Member Author

I updated the several testsuite branches and removed the two tests from the blacklist, basically with the same procedure as in #172

@perlpunk perlpunk deleted the perlpunk/open-ended branch April 11, 2020 17:53
perlpunk added a commit that referenced this pull request Apr 17, 2020
open_ended can have two states:
1: The previous document wasn't ended with ...
2: the last scalar event was a block scalar with trailing empty lines |+

This was broken in the past, and fixed in fa1293a.
With my last PR #162 I added the faulty behaviour again.

The problematic behaviour showed only when:
* writing YAML directives
* writing unquoted top level scalars
* writing more than one document

================== BROKEN ==============================

The first example shows that the document end marker is not emitted before
the next document. This would be valid in YAML 1.1 if the scalar was quoted,
but not if it is plain.

This commit fixes this.

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1

%YAML 1.1
--- foo
%YAML 1.1
--- bar

================== FIXED ==============================

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

=======================================================

Other examples which should look like this (and were correct already before
this fix):

Open ended scalars like |+ need '...' at the end of the stream:

echo '--- |+
  a

--- |+
  a

' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite
--- |+
  a

--- |+
  a

...

=======================================================

If a document is ended with an explicit '...', the code should not
print '...' twice:

echo '--- foo
...
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

==========================================================
perlpunk added a commit that referenced this pull request Apr 19, 2020
open_ended can have three states now:
0: The previous document was ended explicitly with '...'
1: The previous document wasn't ended with '...'
2: The last scalar event was a block scalar with trailing empty lines |+, and
   last document wasn't ended with '...'.
   Important at stream end.

This was broken in the past, and fixed in fa1293a.
With my last PR #162 I added the faulty behaviour again.

The problematic behaviour showed only when all of the following conditions were
true:
* writing YAML directives
* writing unquoted top level scalars
* writing more than one document

================== BROKEN ==============================

The first example shows that the document end marker is not emitted before
the next document. This would be valid in YAML 1.1 if the scalar was quoted,
but not if it is plain.

This commit fixes this.

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1

%YAML 1.1
--- foo
%YAML 1.1
--- bar

================== FIXED ==============================

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

=======================================================

Other examples which should look like this (and were correct already before
this fix):

Open ended scalars like |+ need '...' at the end of the stream:

echo '--- |+
  a

--- |+
  a

' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite
--- |+
  a

--- |+
  a

...

=======================================================

If a document is ended with an explicit '...', the code should not
print '...' twice:

echo '--- foo
...
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

==========================================================
perlpunk added a commit that referenced this pull request Apr 19, 2020
open_ended can have three states now:
0: The previous document was ended explicitly with '...'
1: The previous document wasn't ended with '...'
2: The last scalar event was a block scalar with trailing empty lines |+, and
   last document wasn't ended with '...'.
   Important at stream end.

This was broken in the past, and fixed in fa1293a.
With my last PR #162 I added the faulty behaviour again.

The problematic behaviour showed only when all of the following conditions were
true:
* writing YAML directives
* writing unquoted top level scalars
* writing more than one document

================== BROKEN ==============================

The first example shows that the document end marker is not emitted before
the next document. This would be valid in YAML 1.1 if the scalar was quoted,
but not if it is plain.

This commit fixes this.

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1

%YAML 1.1
--- foo
%YAML 1.1
--- bar

================== FIXED ==============================

echo '--- foo
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite  --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

=======================================================

Other examples which should look like this (and were correct already before
this fix):

Open ended scalars like |+ need '...' at the end of the stream:

echo '--- |+
  a

--- |+
  a

' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite
--- |+
  a

--- |+
  a

...

=======================================================

If a document is ended with an explicit '...', the code should not
print '...' twice:

echo '--- foo
...
--- bar
' | ./tests/run-parser-test-suite  | ./tests/run-emitter-test-suite --directive 1.1
%YAML 1.1
--- foo
...
%YAML 1.1
--- bar

==========================================================
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