# 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 Program.ConvertToLibYamlStyleAnnotatedEventStream(TextReader textReader, 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:219)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:173)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:138)
	at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:494)
	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:122)
	at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:659)
	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:322)
	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:331)
	... 7 more

js-jsyaml-json

 invalid_correct
/node/node_modules/js-yaml/lib/js-yaml/loader.js:173
  throw generateError(state, message);
  ^
YAMLException: unknown tag !<!foo> at line 1, column 11:
    !foo "bar"
              ^
    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 composeNode (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1428:7)
    at readDocument (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1519:3)
    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)

js-yaml-event

 invalid_correct
Document contains trailing content not separated by a ... or --- line
+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]
                               ^

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)

nim-nimyaml-event

 invalid_correct
/buildutils/nimyaml_event.nim(8) nimyaml_event
/tmp/NimYAML-0.13.1/yaml/stream.nim(223) finished
Error: unhandled exception: Unexpected token (expected document end): ltScalarPart [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 386
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 386
YAML      : "%TAG ! tag:example.com,2000:app/"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 92.

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 386
YAML      : "%TAG ! tag:example.com,2000:app/"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 92.

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.