# YAML Test Matrix

--- &test-9WXW
  Title: Spec Example 6.18. Primary Tag Handle
  Tags: [ 1.3-err, directive, local-tag, spec, tag, unknown-tag ]

YAML

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

Expected Events

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

Expected JSON

"bar"
"bar"

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

c-libfyaml-json

 json_ok

go-yaml-json

 json_ok

hs-hsyaml-json

 json_ok

js-yaml-json

 json_ok

lua-lyaml-json

 json_ok

perl-pp-json

 json_ok

perl-pplibyaml-json

 json_ok

py-pyyaml-json

 json_ok

py-ruamel-json

 json_ok

ruby-psych-json

 json_ok

cpp-rapidyaml-event

 diff
Minimal Events:
+STR
+DOC
=VAL <!foo> :bar
-DOC ...
+DOC ---
=VAL <tag:example.com,2000:app/foo> :bar
-DOC
-STR
Transformed Events:
+STR
+DOC ---
=VAL <!foo> :bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> :bar
-DOC
-STR
Got Events:
+STR
+DOC ---
=VAL <!foo> 'bar
-DOC
+DOC ---
=VAL <tag:example.com,2000:app/foo> 'bar
-DOC
-STR

rust-yamlrust-event

 diff
Minimal Events:
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC
=VAL <tag:example.com,2000:app/foo> "bar
-DOC
-STR
Transformed Events:
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC
=VAL <!foo> "bar
-DOC
-STR
Got Events:
+STR
+DOC
=VAL <!foo> "bar
-DOC
+DOC
=VAL <!foo> "bar
-DOC
-STR

perl-syck-json

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

perl-yaml-json

 error
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

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

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +COMM|
   1    0    0    0 =SYNX|#
   1    1    1    1 =META|.Private
   1    9    9    9 -COMM|
   1    9    9    9 =EOL |\x0a
   2    0   10   10 +DOC |
   2    0   10   10 +NODE|
   2    0   10   10 +PROP|
   2    0   10   10 +TAG |
   2    0   10   10 +HAND|
   2    0   10   10 =SYNX|!
   2    1   11   11 -HAND|
   2    1   11   11 =META|foo
   2    4   14   14 -TAG |
   2    4   14   14 -PROP|
   2    4   14   14 =WSPC|.
   2    5   15   15 +VAL |
   2    5   15   15 =SYNX|"
   2    6   16   16 =TEXT|bar
   2    9   19   19 =SYNX|"
   2   10   20   20 -VAL |
   2   10   20   20 -NODE|
   2   10   20   20 =EOL |\x0a
   3    0   21   21 -DOC |
   3    0   21   21 =FOOT|...
   3    3   24   24 =EOL |\x0a
   4    0   25   25 +COMM|
   4    0   25   25 =SYNX|#
   4    1   26   26 =META|.Global
   4    8   33   33 -COMM|
   4    8   33   33 =EOL |\x0a
   5    0   34   34 +DOC |
   5    0   34   34 +DIR |
   5    0   34   34 =SYNX|%
   5    1   35   35 =META|TAG
   5    4   38   38 =WSPC|.
   5    5   39   39 +HAND|
   5    5   39   39 =SYNX|!
   5    6   40   40 -HAND|
   5    6   40   40 =WSPC|.
   5    7   41   41 +TAG |
   5    7   41   41 =META|tag:example.com,2000:app/
   5   32   66   66 -TAG |
   5   32   66   66 -DIR |
   5   32   66   66 =EOL |\x0a
   6    0   67   67 =HEAD|---
   6    3   70   70 =EOL |\x0a
   7    0   71   71 +NODE|
   7    0   71   71 +PROP|
   7    0   71   71 +TAG |
   7    0   71   71 +HAND|
   7    0   71   71 =SYNX|!
   7    1   72   72 -HAND|
   7    1   72   72 =META|foo
   7    4   75   75 -TAG |
   7    4   75   75 -PROP|
   7    4   75   75 =WSPC|.
   7    5   76   76 +VAL |
   7    5   76   76 =SYNX|"
   7    6   77   77 =TEXT|bar
   7    9   80   80 =SYNX|"
   7   10   81   81 -VAL |
   7   10   81   81 -NODE|
   7   10   81   81 =EOL |\x0a
   8    0   82   82 -DOC |

perl-pp-perl

 na
'bar'
'bar'

perl-pplibyaml-perl

 na
'bar'
'bar'

perl-syck-perl

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

py-pyyaml-py

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

py-ruamel-py

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

dotnet-yamldotnet-json

 ni
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 2, Col: 1, Idx: 10) - (Line: 2, Col: 11, Idx: 20): 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)

js-jsyaml-json

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

 1 | # Private
 2 | !foo "bar"
---------------^
 3 | ...
 4 | # Global
    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 (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) {
  reason: 'unknown tag !<!foo>',
  mark: {
    name: null,
    buffer: '# Private\n' +
      '!foo "bar"\n' +
      '...\n' +
      '# Global\n' +
      '%TAG ! tag:example.com,2000:app/\n' +
      '---\n' +
      '!foo "bar"\n',
    position: 20,
    line: 1,
    column: 10,
    snippet: ' 1 | # Private\n 2 | !foo "bar"\n---------------^\n 3 | ...\n 4 | # Global'
  }
}

Node.js v20.13.1

perl-tiny-json

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

perl-tiny-perl

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

perl-xs-json

 ni
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

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