# YAML Test Matrix

--- &test-RHX7
  Title: YAML directive without document end marker
  Tags: [ directive, error ]

YAML

---
key: value
%YAML 1.2
---

Expected Events

+STR
+DOC ---
+MAP
=VAL :key
=VAL :value

Expected JSON



c-libyaml-event

 invalid_incorrect
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
-MAP
-DOC
+DOC ---
=VAL :
-DOC
-STR

cpp-yamlcpp-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :key
=VAL :value
-MAP
-DOC
+DOC
=VAL :
-DOC
-STR

java-snakeyaml-event

 invalid_incorrect
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
-MAP
-DOC
+DOC ---
=VAL :
-DOC
-STR

java-snakeyaml-json

 invalid_incorrect
{
  "key": "value"
}
null

perl-pplibyaml-event

 invalid_incorrect
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
-MAP
-DOC
+DOC ---
=VAL :
-DOC
-STR

perl-pplibyaml-json

 invalid_incorrect
{
   "key" : "value"
}
null

perl-pplibyaml-perl

 invalid_incorrect
{
  'key' => 'value'
}
undef

perl-xs-json

 invalid_incorrect
{
   "key" : "value"
}
null

perl-xs-perl

 invalid_incorrect
{
  'key' => 'value'
}
undef

py-pyyaml-event

 invalid_incorrect
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
-MAP
-DOC
+DOC ---
=VAL :
-DOC
-STR

py-pyyaml-json

 invalid_incorrect
{
  "key": "value"
}
null

py-pyyaml-py

 invalid_incorrect
{'key': 'value'}
None

py-ruamel-event

 invalid_incorrect
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
-MAP
-DOC
+DOC ---
=VAL :
-DOC
-STR

py-ruamel-json

 invalid_incorrect
{
  "key": "value"
}
null

py-ruamel-py

 invalid_incorrect
{'key': 'value'}
None

c-libfyaml-event

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

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: 15) - (Line: 3, Col: 6, Idx: 20): While scanning a version directive, did not find preceding <document end>.
   at YamlDotNet.Core.Scanner.ScanDirective()
   at YamlDotNet.Core.Scanner.FetchDirective()
   at YamlDotNet.Core.Scanner.FetchNextToken()
   at YamlDotNet.Core.Scanner.FetchMoreTokens()
   at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming()
   at YamlDotNet.Core.Parser.GetCurrentToken()
   at YamlDotNet.Core.Parser.ParseBlockMappingKey(Boolean isFirst)
   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 ---
+MAP
=VAL :key
=VAL :value

dotnet-yamldotnet-json

 invalid_correct
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 3, Col: 1, Idx: 15) - (Line: 3, Col: 6, Idx: 20): While scanning a version directive, did not find preceding <document end>.
   at YamlDotNet.Core.Scanner.ScanDirective()
   at YamlDotNet.Core.Scanner.FetchDirective()
   at YamlDotNet.Core.Scanner.FetchNextToken()
   at YamlDotNet.Core.Scanner.FetchMoreTokens()
   at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming()
   at YamlDotNet.Core.Parser.GetCurrentToken()
   at YamlDotNet.Core.Parser.ParseBlockMappingKey(Boolean isFirst)
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.TryConsume[T](IParser parser, T& event)
   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.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.DeserializeHelper(Type tKey, Type tValue, IParser parser, Func`3 nestedObjectDeserializer, IDictionary result)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.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 = 15, posCharOffset = 15, posLine = 3, posColumn = 0} (Unexpected '%')
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
-MAP
-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 | key: value
 3 | %YAML 1.2
-----^
 4 | ---
    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 (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
Plain value cannot start with directive indicator character % at line 3, column 1:

key: value
%YAML 1.2
^
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value

js-yaml-json

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

YAMLParseError: Plain value cannot start with directive indicator character % at line 3, column 1:

key: value
%YAML 1.2
^

    at Composer.onError (/node/node_modules/yaml/dist/compose/composer.js:71:34)
    at _onError (/node/node_modules/yaml/dist/compose/resolve-flow-scalar.js:10:42)
    at plainValue (/node/node_modules/yaml/dist/compose/resolve-flow-scalar.js:68:9)
    at Object.resolveFlowScalar (/node/node_modules/yaml/dist/compose/resolve-flow-scalar.js:14:21)
    at Object.composeScalar (/node/node_modules/yaml/dist/compose/compose-scalar.js:11:29)
    at composeNode (/node/node_modules/yaml/dist/compose/compose-node.js:23:34)
    at Object.resolveBlockMap (/node/node_modules/yaml/dist/compose/resolve-block-map.js:50:15)
    at Object.composeCollection (/node/node_modules/yaml/dist/compose/compose-collection.js:13:36)
    at Object.composeNode (/node/node_modules/yaml/dist/compose/compose-node.js:30:38)
    at Object.composeDoc (/node/node_modules/yaml/dist/compose/compose-doc.js:31:23)

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:306: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:325: in function 'parse'
	/usr/local/share/lua/5.1/lyaml/init.lua:496: in function 'load'
	/yaml/bin/lua-lyaml-json:6: in main chunk
	[C]: at 0x55ef2db7ff97

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 ':'): DirectivesEnd [YamlStreamError]
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value
=VAL :%YAML 1.2

perl-pp-event

 invalid_correct
Line      : 3
Column    : 1
Expected  : ALIAS COLON DOC_END DOC_START EOL PLAIN QUESTION QUOTED
Got       : YAML_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%YAML 1.2"
  at /yaml/bin/perl-pp-event line 25.
+STR
+DOC ---
+MAP
=VAL :key
=VAL :value

perl-pp-json

 invalid_correct
Line      : 3
Column    : 1
Expected  : ALIAS COLON DOC_END DOC_START EOL PLAIN QUESTION QUOTED
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  : ALIAS COLON DOC_END DOC_START EOL PLAIN QUESTION QUOTED
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 4047, <> line 1.

perl-syck-json

 invalid_correct
Syck parser (line 4, column 0): 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 4, column 0): 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 '%YAML 1.2' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 invalid_correct
YAML::Tiny failed to classify line '%YAML 1.2' at /yaml/bin/perl-tiny-perl line 15.

perl-yaml-json

 invalid_correct
Use of uninitialized value in sprintf at /perl5/lib/perl5/YAML/Error.pm line 18, <> line 1.
YAML Error: Can't parse inline implicit value ''
   Code: YAML_PARSE_ERR_BAD_INLINE_IMPLICIT
   Line: 3
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 607.

perl-yaml-perl

 invalid_correct
Use of uninitialized value in sprintf at /perl5/lib/perl5/YAML/Error.pm line 18, <> line 1.
YAML Error: Can't parse inline implicit value ''
   Code: YAML_PARSE_ERR_BAD_INLINE_IMPLICIT
   Line: 3
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 607.

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