# YAML Test Matrix

--- &test-EB22
  Title: Missing document-end marker before directive
  Tags: [ directive, error, footer ]

YAML

---
scalar1 # comment
%YAML 1.2
---
scalar2

Expected Events

+STR
+DOC ---
=VAL :scalar1
-DOC

Expected JSON



c-libyaml-event

 invalid_incorrect
+STR
+DOC ---
=VAL :scalar1
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

cpp-rapidyaml-event

 invalid_incorrect
+STR
+DOC ---
=VAL :scalar1
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

cpp-yamlcpp-event

 invalid_incorrect
+STR
+DOC
=VAL :scalar1
-DOC
+DOC
=VAL :scalar2
-DOC
-STR

hs-reference-yeast

 invalid_incorrect
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 =HEAD|---
   1    3    3    3 =EOL |\x0a
   2    0    4    4 +NODE|
   2    0    4    4 +VAL |
   2    0    4    4 =TEXT|scalar1
   2    7   11   11 -VAL |
   2    7   11   11 -NODE|
   2    7   11   11 =WSPC|.
   2    8   12   12 +COMM|
   2    8   12   12 =SYNX|#
   2    9   13   13 =META|.comment
   2   17   21   21 -COMM|
   2   17   21   21 =EOL |\x0a
   3    0   22   22 -DOC |
   3    0   22   22 =ERR |Unexpected.'%'

lua-lyaml-json

 invalid_incorrect
"scalar1"
"scalar2"

perl-pplibyaml-json

 invalid_incorrect
"scalar1"
"scalar2"

perl-pplibyaml-perl

 invalid_incorrect
'scalar1'
'scalar2'

perl-xs-json

 invalid_incorrect
"scalar1"
"scalar2"

perl-xs-perl

 invalid_incorrect
'scalar1'
'scalar2'

py-pyyaml-event

 invalid_incorrect
+STR
+DOC ---
=VAL :scalar1
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

py-pyyaml-json

 invalid_incorrect
"scalar1"
"scalar2"

py-pyyaml-py

 invalid_incorrect
'scalar1'
'scalar2'

py-ruamel-event

 invalid_incorrect
+STR
+DOC ---
=VAL :scalar1
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

py-ruamel-json

 invalid_incorrect
"scalar1"
"scalar2"

py-ruamel-py

 invalid_incorrect
'scalar1'
'scalar2'

ruby-psych-json

 invalid_incorrect
"scalar1"
"scalar2"

rust-yamlrust-event

 invalid_incorrect
+STR
+DOC
=VAL :scalar1
-DOC
+DOC
=VAL :scalar2
-DOC
-STR

c-libfyaml-event

 invalid_correct
stdin:3:7: error: missing explicit document end marker before directive(s)
%YAML 1.2
      ^~~
+STR
+DOC ---
=VAL :scalar1

c-libfyaml-json

 invalid_correct
stdin:3:7: error: missing explicit document end marker before directive(s)
%YAML 1.2
      ^~~

dotnet-yamldotnet-event

 invalid_correct
Unhandled exception. YamlDotNet.Core.SyntaxErrorException: (Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 1, Idx: 0): While parsing a document start node, could not find document end marker before version directive.
   at YamlDotNet.Core.Parser.ParseDocumentStart(Boolean isImplicit)
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.RepresentationModel.LibYamlEventStream.WriteTo(TextWriter textWriter)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)
+STR
+DOC ---
=VAL :scalar1
-DOC

dotnet-yamldotnet-json

 invalid_correct
Unhandled exception. YamlDotNet.Core.SyntaxErrorException: (Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 1, Idx: 0): While parsing a document start node, could not find document end marker before version directive.
   at YamlDotNet.Core.Parser.ParseDocumentStart(Boolean isImplicit)
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.Consume[T](IParser parser)
   at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)

go-yaml-json

 invalid_correct
yaml: line 2: found incompatible YAML document
"scalar1"

hs-hsyaml-event

 invalid_correct
Parsing error near byte offset Pos {posByteOffset = 22, posCharOffset = 22, posLine = 3, posColumn = 0} (Unexpected '%')
+STR
+DOC ---
=VAL :scalar1
-DOC

hs-hsyaml-json

 invalid_correct
hsyaml-parser: user error (Unexpected '%')

js-jsyaml-json

 invalid_correct
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: end of the stream or a document separator is expected (3:1)

 1 | ---
 2 | scalar1 # comment
 3 | %YAML 1.2
-----^
 4 | ---
 5 | scalar2
    at generateError (/node/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/node/node_modules/js-yaml/lib/loader.js:187:9)
    at readDocument (/node/node_modules/js-yaml/lib/loader.js:1645:5)
    at loadDocuments (/node/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.loadAll (/node/node_modules/js-yaml/lib/loader.js:1701:19)
    at Object.<anonymous> (/yaml/bin/js-jsyaml-json:7:13)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12) {
  reason: 'end of the stream or a document separator is expected',
  mark: {
    name: null,
    buffer: '---\nscalar1 # comment\n%YAML 1.2\n---\nscalar2\n',
    position: 22,
    line: 2,
    column: 0,
    snippet: ' 1 | ---\n' +
      ' 2 | scalar1 # comment\n' +
      ' 3 | %YAML 1.2\n' +
      '-----^\n' +
      ' 4 | ---\n' +
      ' 5 | scalar2'
  }
}

Node.js v20.13.1

js-yaml-event

 invalid_correct
Unexpected scalar at node end at line 3, column 1:

scalar1 # comment
%YAML 1.2
^^^^^^^^^
+STR
+DOC ---
=VAL :scalar1
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

js-yaml-json

 invalid_correct
/yaml/bin/js-yaml-json:9
    if (doc.errors.length !== 0) throw doc.errors[0]
                                 ^

YAMLParseError: Unexpected scalar at node end at line 3, column 1:

scalar1 # comment
%YAML 1.2
^^^^^^^^^

    at Composer.onError (/node/node_modules/yaml/dist/compose/composer.js:69:34)
    at Object.resolveEnd (/node/node_modules/yaml/dist/compose/resolve-end.js:31:21)
    at Object.composeDoc (/node/node_modules/yaml/dist/compose/compose-doc.js:37:27)
    at Composer.next (/node/node_modules/yaml/dist/compose/composer.js:149:40)
    at next (<anonymous>)
    at Composer.compose (/node/node_modules/yaml/dist/compose/composer.js:131:25)
    at compose.next (<anonymous>)
    at Function.from (<anonymous>)
    at Object.parseAllDocuments (/node/node_modules/yaml/dist/public-api.js:28:24)
    at Object.<anonymous> (/yaml/bin/js-yaml-json:7:19) {
  code: 'UNEXPECTED_TOKEN',
  pos: [ 22, 31 ],
  linePos: [ { line: 3, col: 1 }, { line: 3, col: 10 } ]
}

Node.js v20.13.1

nim-nimyaml-event

 invalid_correct
/tmp/NimYAML-0.16.0/yaml/stream.nim(134) nimyaml_event
/tmp/NimYAML-0.16.0/yaml/stream.nim(106) next
Error: unhandled exception: Unexpected token (expected document end): Indentation [YamlStreamError]
+STR
+DOC ---
=VAL :scalar1

perl-pp-event

 invalid_correct
Line      : 3
Column    : 1
Expected  : DOC_END DOC_START EOL
Got       : YAML_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%YAML 1.2"
  at /yaml/bin/perl-pp-event line 46.
+STR
+DOC ---
=VAL :scalar1

perl-pp-json

 invalid_correct
Line      : 3
Column    : 1
Expected  : DOC_END DOC_START EOL
Got       : YAML_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%YAML 1.2"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pp-perl

 invalid_correct
Line      : 3
Column    : 1
Expected  : DOC_END DOC_START EOL
Got       : YAML_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%YAML 1.2"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-refparser-event

 invalid_correct
Parser finished before end of input at /perl5/lib/perl5/YAML/Parser.pm line 4056, <> line 1.

perl-syck-json

 invalid_correct
Syck parser (line 6, column -1): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

perl-syck-perl

 invalid_correct
Syck parser (line 6, column -1): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

perl-tiny-json

 invalid_correct
YAML::Tiny failed to classify line 'scalar1 # comment' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 invalid_correct
YAML::Tiny failed to classify line 'scalar1 # comment' at /yaml/bin/perl-tiny-perl line 15.

perl-yaml-json

 invalid_correct
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 2
   Document: 2
 at /perl5/lib/perl5/YAML/Loader.pm line 88.

perl-yaml-perl

 invalid_correct
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 2
   Document: 2
 at /perl5/lib/perl5/YAML/Loader.pm line 88.