# 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-yamlcpp-event

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

java-snakeyaml-event

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

java-snakeyaml-json

 invalid_incorrect
"scalar1"
"scalar2"

nim-nimyaml-event

 invalid_incorrect
+STR
+DOC ---
=VAL :scalar1 %YAML 1.2
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

perl-pplibyaml-event

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

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'

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.SemanticErrorException: (Line: 3, Col: 1, Idx: 22) - (Line: 3, Col: 1, Idx: 22): Did not find expected <document end>.
   at YamlDotNet.Core.Parser.ParseDocumentEnd()
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at Program.ConvertToLibYamlStyleAnnotatedEventStream(TextReader textReader, TextWriter textWriter)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)
+STR
+DOC ---
=VAL :scalar1

dotnet-yamldotnet-json

 invalid_correct
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 3, Col: 1, Idx: 22) - (Line: 3, Col: 1, Idx: 22): Did not find expected <document end>.
   at YamlDotNet.Core.Parser.ParseDocumentEnd()
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.Allow[T](IParser parser)
   at YamlDotNet.Serialization.NodeDeserializers.ScalarNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   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)

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/js-yaml/loader.js:173
  throw generateError(state, message);
  ^
YAMLException: end of the stream or a document separator is expected at line 3, column 1:
    %YAML 1.2
    ^
    at generateError (/node/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
    at throwError (/node/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
    at readDocument (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1539:5)
    at loadDocuments (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1575:5)
    at Object.loadAll (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1583:19)
    at Object.<anonymous> (/yaml/bin/js-jsyaml-json:7:13)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

js-yaml-event

 invalid_correct
Document contains trailing content not separated by a ... or --- line
+STR
+DOC ---
=VAL :scalar1
-DOC
+DOC ---
=VAL :scalar2
-DOC
-STR

js-yaml-json

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

YAMLSyntaxError: Document contains trailing content not separated by a ... or --- line
    at parseContents (/node/node_modules/yaml/dist/Document-2cf6b08c.js:353:25)
    at Document.parse (/node/node_modules/yaml/dist/Document-2cf6b08c.js:615:5)
    at Object.parseAllDocuments (/node/node_modules/yaml/dist/index.js:34:9)
    at Object.<anonymous> (/yaml/bin/js-yaml-json:7:19)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)

lua-lyaml-json

 invalid_correct
luajit: 3:1: found incompatible YAML document
stack traceback:
	[C]: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:291: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:310: in function 'parse'
	/usr/local/share/lua/5.1/lyaml/init.lua:481: in function 'load'
	/yaml/bin/lua-lyaml-json:6: in main chunk
	[C]: at 0x560ff2373f97

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 386
YAML      : "%YAML 1.2"
  at /yaml/bin/perl-pp-event line 25.
+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 386
YAML      : "%YAML 1.2"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 92.

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 386
YAML      : "%YAML 1.2"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 92.

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.

ruby-psych-json

 invalid_correct
/usr/lib/ruby/2.5.0/psych.rb:405:in `parse': (<unknown>): found incompatible YAML document at line 1 column 1 (Psych::SyntaxError)
	from /usr/lib/ruby/2.5.0/psych.rb:405:in `parse_stream'
	from /usr/lib/ruby/2.5.0/psych.rb:488:in `load_stream'
	from /yaml/bin/ruby-psych-json:6:in `<main>'