# YAML Test Matrix

--- &test-6CK3
  Title: Spec Example 6.26. Tag Shorthands
  Tags: [ local-tag, spec, tag ]

YAML

%TAG !e! tag:example.com,2000:app/
---
- !local foo
- !!str bar
- !e!tag%21 baz

Expected Events

+STR
+DOC ---
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <tag:example.com,2000:app/tag!> :baz
-SEQ
-DOC
-STR

Expected JSON

[
"foo",
"bar",
"baz"
]

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-rapidyaml-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-yamlcpp-event

 diff
Minimal Events:
+STR
+DOC
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <tag:example.com,2000:app/tag!> :baz
-SEQ
-DOC
-STR
Transformed Events:
+STR
+DOC
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <tag:example.com,2000:app/tag%21> :baz
-SEQ
-DOC
-STR
Got Events:
+STR
+DOC
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <tag:example.com,2000:app/tag%21> :baz
-SEQ
-DOC
-STR

rust-yamlrust-event

 diff
Minimal Events:
+STR
+DOC
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <tag:example.com,2000:app/tag!> :baz
-SEQ
-DOC
-STR
Transformed Events:
+STR
+DOC
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <!e!tag!> :baz
-SEQ
-DOC
-STR
Got Events:
+STR
+DOC
+SEQ
=VAL <!local> :foo
=VAL <tag:yaml.org,2002:str> :bar
=VAL <!e!tag!> :baz
-SEQ
-DOC
-STR

perl-syck-json

 json_diff
"%TAG !e! tag:example.com,2000:app/ --- - !local foo - !!str bar - !e!tag%21 baz"

perl-xs-json

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

perl-xs-perl

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

perl-yaml-json

 error
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

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 1
   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 +DOC |
   1    0    0    0 +DIR |
   1    0    0    0 =SYNX|%
   1    1    1    1 =META|TAG
   1    4    4    4 =WSPC|.
   1    5    5    5 +HAND|
   1    5    5    5 =SYNX|!
   1    6    6    6 =META|e
   1    7    7    7 =SYNX|!
   1    8    8    8 -HAND|
   1    8    8    8 =WSPC|.
   1    9    9    9 +TAG |
   1    9    9    9 =META|tag:example.com,2000:app/
   1   34   34   34 -TAG |
   1   34   34   34 -DIR |
   1   34   34   34 =EOL |\x0a
   2    0   35   35 =HEAD|---
   2    3   38   38 +NODE|
   2    3   38   38 =EOL |\x0a
   3    0   39   39 +SEQ |
   3    0   39   39 =SYNX|-
   3    1   40   40 =WSPC|.
   3    2   41   41 +NODE|
   3    2   41   41 +PROP|
   3    2   41   41 +TAG |
   3    2   41   41 +HAND|
   3    2   41   41 =SYNX|!
   3    3   42   42 -HAND|
   3    3   42   42 =META|local
   3    8   47   47 -TAG |
   3    8   47   47 -PROP|
   3    8   47   47 =WSPC|.
   3    9   48   48 +VAL |
   3    9   48   48 =TEXT|foo
   3   12   51   51 -VAL |
   3   12   51   51 -NODE|
   3   12   51   51 =EOL |\x0a
   4    0   52   52 =SYNX|-
   4    1   53   53 =WSPC|.
   4    2   54   54 +NODE|
   4    2   54   54 +PROP|
   4    2   54   54 +TAG |
   4    2   54   54 +HAND|
   4    2   54   54 =SYNX|!
   4    3   55   55 =SYNX|!
   4    4   56   56 -HAND|
   4    4   56   56 =META|str
   4    7   59   59 -TAG |
   4    7   59   59 -PROP|
   4    7   59   59 =WSPC|.
   4    8   60   60 +VAL |
   4    8   60   60 =TEXT|bar
   4   11   63   63 -VAL |
   4   11   63   63 -NODE|
   4   11   63   63 =EOL |\x0a
   5    0   64   64 =SYNX|-
   5    1   65   65 =WSPC|.
   5    2   66   66 +NODE|
   5    2   66   66 +PROP|
   5    2   66   66 +TAG |
   5    2   66   66 +HAND|
   5    2   66   66 =SYNX|!
   5    3   67   67 =META|e
   5    4   68   68 =SYNX|!
   5    5   69   69 -HAND|
   5    5   69   69 =META|tag%21
   5   11   75   75 -TAG |
   5   11   75   75 -PROP|
   5   11   75   75 =WSPC|.
   5   12   76   76 +VAL |
   5   12   76   76 =TEXT|baz
   5   15   79   79 -VAL |
   5   15   79   79 -NODE|
   5   15   79   79 =EOL |\x0a
   6    0   80   80 -SEQ |
   6    0   80   80 -NODE|
   6    0   80   80 -DOC |

perl-pp-perl

 na
[
  'foo',
  'bar',
  'baz'
]

perl-pplibyaml-perl

 na
[
  'foo',
  'bar',
  'baz'
]

perl-syck-perl

 na
'%TAG !e! tag:example.com,2000:app/ --- - !local foo - !!str bar - !e!tag%21 baz'

py-pyyaml-py

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

py-ruamel-py

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

dotnet-yamldotnet-json

 ni
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 3, Col: 3, Idx: 41) - (Line: 3, Col: 13, Idx: 51): Encountered an unresolved tag '!local'
   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.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.DeserializeHelper(Type tItem, IParser parser, Func`3 nestedObjectDeserializer, IList result, Boolean canUpdate)
   at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.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)

js-jsyaml-json

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

 1 | %TAG !e! tag:example.com,2000:app/
 2 | ---
 3 | - !local foo
-----------------^
 4 | - !!str bar
 5 | - !e!tag%21 baz
    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 readBlockSequence (/node/node_modules/js-yaml/lib/loader.js:1008:5)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1440:12)
    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) {
  reason: 'unknown tag !<!local>',
  mark: {
    name: null,
    buffer: '%TAG !e! tag:example.com,2000:app/\n' +
      '---\n' +
      '- !local foo\n' +
      '- !!str bar\n' +
      '- !e!tag%21 baz\n',
    position: 51,
    line: 2,
    column: 12,
    snippet: ' 1 | %TAG !e! tag:example.com,2000:app/\n' +
      ' 2 | ---\n' +
      ' 3 | - !local foo\n' +
      '-----------------^\n' +
      ' 4 | - !!str bar\n' +
      ' 5 | - !e!tag%21 baz'
  }
}

Node.js v20.13.1

perl-tiny-json

 ni
YAML::Tiny failed to classify line '%TAG !e! tag:example.com,2000:app/' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 ni
YAML::Tiny failed to classify line '%TAG !e! tag:example.com,2000:app/' at /yaml/bin/perl-tiny-perl line 15.