# YAML Test Matrix

--- &test-9HCY
  Title: Need document footer before directives
  Tags: [ directive, error, footer, tag, unknown-tag ]

YAML

!foo "bar"
%TAG ! tag:example.com,2000:app/
---
!foo "bar"

Expected Events

+STR
+DOC
=VAL <!foo> "bar

Expected JSON



c-libyaml-event

 invalid_incorrect
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> "bar
-DOC
-STR

cpp-yamlcpp-event

 invalid_incorrect
+STR
+DOC
=VAL <!foo> :bar
-DOC
+DOC
=VAL <tag:example.com,2000:app/foo> :bar
-DOC
-STR

java-snakeyaml-event

 invalid_incorrect
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> "bar
-DOC
-STR

lua-lyaml-json

 invalid_incorrect
"bar"
"bar"

perl-pplibyaml-event

 invalid_incorrect
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> "bar
-DOC
-STR

perl-pplibyaml-json

 invalid_incorrect
"bar"
"bar"

perl-pplibyaml-perl

 invalid_incorrect
'bar'
'bar'

py-pyyaml-event

 invalid_incorrect
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> "bar
-DOC
-STR

py-pyyaml-json

 invalid_incorrect
"bar"
"bar"

py-pyyaml-py

 invalid_incorrect
GenericScalar(tag='!foo', content='bar')
GenericScalar(tag='tag:example.com,2000:app/foo', content='bar')

py-ruamel-event

 invalid_incorrect
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> "bar
-DOC
-STR

py-ruamel-json

 invalid_incorrect
"bar"
"bar"

py-ruamel-py

 invalid_incorrect
GenericScalar(tag='!foo', content='bar')
GenericScalar(tag='tag:example.com,2000:app/foo', content='bar')

ruby-psych-json

 invalid_incorrect
"bar"
"bar"

c-libfyaml-event

 invalid_correct
stdin:2:6: error: missing explicit document end marker before directive(s)
%TAG ! tag:example.com,2000:app/
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
+STR
+DOC
=VAL <!foo> "bar

c-libfyaml-json

 invalid_correct
stdin:2:6: error: missing explicit document end marker before directive(s)
%TAG ! tag:example.com,2000:app/
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

dotnet-yamldotnet-event

 invalid_correct
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 2, Col: 1, Idx: 11) - (Line: 2, Col: 1, Idx: 11): Did not find expected <document end>.
   at YamlDotNet.Core.Parser.ParseDocumentEnd()
   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 <!foo> "bar

dotnet-yamldotnet-json

 invalid_correct
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 11, Idx: 10): Encountered an unresolved tag '!foo'
   at YamlDotNet.Serialization.NodeTypeResolvers.PreventUnknownTagsNodeTypeResolver.YamlDotNet.Serialization.INodeTypeResolver.Resolve(NodeEvent nodeEvent, Type& currentType)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.GetTypeFromEvent(NodeEvent nodeEvent, Type currentType)
   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 = 11, posCharOffset = 11, posLine = 2, posColumn = 0} (Unexpected '%')
+STR
+DOC
=VAL <!foo> "bar
-DOC

hs-hsyaml-json

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

java-snakeyaml-json

 invalid_correct
Exception in thread "main" Can't construct a java object for !foo; exception=Invalid tag: !foo
 in 'reader', line 1, column 1:
    !foo "bar"
    ^

	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:220)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:174)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:139)
	at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:514)
	at org.yaml.editor.Snake2Json.yamlToJson(Snake2Json.java:18)
	at org.yaml.editor.Snake2Json.main(Snake2Json.java:25)
Caused by: org.yaml.snakeyaml.error.YAMLException: Invalid tag: !foo
	at org.yaml.snakeyaml.nodes.Tag.getClassName(Tag.java:125)
	at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:664)
	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:323)
	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:332)
	... 7 more

js-jsyaml-json

 invalid_correct
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: unknown tag !<!foo> (1:11)

 1 | !foo "bar"
---------------^
 2 | %TAG ! tag:example.com,2000:app/
 3 | ---
    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 composeNode (/node/node_modules/js-yaml/lib/loader.js:1521:7)
    at readDocument (/node/node_modules/js-yaml/lib/loader.js:1625:3)
    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)

js-yaml-event

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

!foo "bar"
%TAG ! tag:example.com,2000:app/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC ---
=VAL <!foo> "bar
-DOC
-STR

js-yaml-json

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

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

!foo "bar"
%TAG ! tag:example.com,2000:app/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    at Composer.onError (/node/node_modules/yaml/dist/compose/composer.js:71: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:34:27)
    at Composer.next (/node/node_modules/yaml/dist/compose/composer.js:152:40)
    at next (<anonymous>)
    at Composer.compose (/node/node_modules/yaml/dist/compose/composer.js:134:25)
    at compose.next (<anonymous>)
    at Function.from (<anonymous>)
    at Object.parseAllDocuments (/node/node_modules/yaml/dist/public-api.js:30:24)
    at Object.<anonymous> (/yaml/bin/js-yaml-json:7:19)

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 <!foo> "bar

perl-pp-event

 invalid_correct
Line      : 2
Column    : 1
Expected  : DOC_END DOC_START EOL
Got       : TAG_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%TAG ! tag:example.com,2000:app/"
  at /yaml/bin/perl-pp-event line 25.
+STR
+DOC
=VAL <!foo> "bar

perl-pp-json

 invalid_correct
Line      : 2
Column    : 1
Expected  : DOC_END DOC_START EOL
Got       : TAG_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%TAG ! tag:example.com,2000:app/"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pp-perl

 invalid_correct
Line      : 2
Column    : 1
Expected  : DOC_END DOC_START EOL
Got       : TAG_DIRECTIVE
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 392
YAML      : "%TAG ! tag:example.com,2000:app/"
  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 5, 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 5, 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 '!foo "bar"' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 invalid_correct
YAML::Tiny failed to classify line '!foo "bar"' at /yaml/bin/perl-tiny-perl line 15.

perl-xs-json

 invalid_correct
YAML::XS Error: bad tag found for scalar: 'tag:example.com,2000:app/foo' at /yaml/bin/perl-xs-json line 14, <> line 1.

perl-xs-perl

 invalid_correct
YAML::XS Error: bad tag found for scalar: 'tag:example.com,2000:app/foo' at /yaml/bin/perl-xs-perl line 16, <> line 1.

perl-yaml-json

 invalid_correct
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 1
   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: 1
   Document: 2
 at /perl5/lib/perl5/YAML/Loader.pm line 88.