# YAML Test Matrix

--- &test-9KAX
  Title: Various combinations of tags and anchors
  Tags: [ 1.3-err, anchor, mapping, tag ]

YAML

---
&a1
!!str
scalar1
---
!!str
&a2
scalar2
---
&a3
!!str scalar3
---
&a4 !!map
&a5 !!str key5: value4
---
a6: 1
&anchor6 b6: 2
---
!!map
&a8 !!str key8: value7
---
!!map
!!str &a10 key10: value9
---
!!str &a11
value11

Expected Events

+STR
+DOC ---
=VAL &a1 <tag:yaml.org,2002:str> :scalar1
-DOC
+DOC ---
=VAL &a2 <tag:yaml.org,2002:str> :scalar2
-DOC
+DOC ---
=VAL &a3 <tag:yaml.org,2002:str> :scalar3
-DOC
+DOC ---
+MAP &a4 <tag:yaml.org,2002:map>
=VAL &a5 <tag:yaml.org,2002:str> :key5
=VAL :value4
-MAP
-DOC
+DOC ---
+MAP
=VAL :a6
=VAL :1
=VAL &anchor6 :b6
=VAL :2
-MAP
-DOC
+DOC ---
+MAP <tag:yaml.org,2002:map>
=VAL &a8 <tag:yaml.org,2002:str> :key8
=VAL :value7
-MAP
-DOC
+DOC ---
+MAP <tag:yaml.org,2002:map>
=VAL &a10 <tag:yaml.org,2002:str> :key10
=VAL :value9
-MAP
-DOC
+DOC ---
=VAL &a11 <tag:yaml.org,2002:str> :value11
-DOC
-STR

Expected JSON

"scalar1"
"scalar2"
"scalar3"
{
"key5": "value4"
}
{
"a6": 1,
"b6": 2
}
{
"key8": "value7"
}
{
"key10": "value9"
}
"value11"

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-rapidyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-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

js-yaml-json

 json_ok

lua-lyaml-json

 json_ok

perl-pp-json

 json_ok

perl-pplibyaml-json

 json_ok

perl-xs-json

 json_ok

py-pyyaml-json

 json_ok

py-ruamel-json

 json_ok

ruby-psych-json

 json_ok

rust-yamlrust-event

 diff
Minimal Events:
+STR
+DOC
=VAL &1 <tag:yaml.org,2002:str> :scalar1
-DOC
+DOC
=VAL &1 <tag:yaml.org,2002:str> :scalar2
-DOC
+DOC
=VAL &1 <tag:yaml.org,2002:str> :scalar3
-DOC
+DOC
+MAP &1 <tag:yaml.org,2002:map>
=VAL &2 <tag:yaml.org,2002:str> :key5
=VAL :value4
-MAP
-DOC
+DOC
+MAP
=VAL :a6
=VAL :1
=VAL &1 :b6
=VAL :2
-MAP
-DOC
+DOC
+MAP <tag:yaml.org,2002:map>
=VAL &1 <tag:yaml.org,2002:str> :key8
=VAL :value7
-MAP
-DOC
+DOC
+MAP <tag:yaml.org,2002:map>
=VAL &1 <tag:yaml.org,2002:str> :key10
=VAL :value9
-MAP
-DOC
+DOC
=VAL &1 <tag:yaml.org,2002:str> :value11
-DOC
-STR
Transformed Events:
+STR
+DOC
=VAL &1 <tag:yaml.org,2002:str> :scalar1
-DOC
+DOC
=VAL &2 <tag:yaml.org,2002:str> :scalar2
-DOC
+DOC
=VAL &3 <tag:yaml.org,2002:str> :scalar3
-DOC
+DOC
+MAP &4
=VAL &5 <tag:yaml.org,2002:str> :key5
=VAL :value4
-MAP
-DOC
+DOC
+MAP
=VAL :a6
=VAL :1
=VAL &6 :b6
=VAL :2
-MAP
-DOC
+DOC
+MAP
=VAL &7 <tag:yaml.org,2002:str> :key8
=VAL :value7
-MAP
-DOC
+DOC
+MAP
=VAL &8 <tag:yaml.org,2002:str> :key10
=VAL :value9
-MAP
-DOC
+DOC
=VAL &9 <tag:yaml.org,2002:str> :value11
-DOC
-STR
Got Events:
+STR
+DOC
=VAL &1 <tag:yaml.org,2002:str> :scalar1
-DOC
+DOC
=VAL &2 <tag:yaml.org,2002:str> :scalar2
-DOC
+DOC
=VAL &3 <tag:yaml.org,2002:str> :scalar3
-DOC
+DOC
+MAP &4
=VAL &5 <tag:yaml.org,2002:str> :key5
=VAL :value4
-MAP
-DOC
+DOC
+MAP
=VAL :a6
=VAL :1
=VAL &6 :b6
=VAL :2
-MAP
-DOC
+DOC
+MAP
=VAL &7 <tag:yaml.org,2002:str> :key8
=VAL :value7
-MAP
-DOC
+DOC
+MAP
=VAL &8 <tag:yaml.org,2002:str> :key10
=VAL :value9
-MAP
-DOC
+DOC
=VAL &9 <tag:yaml.org,2002:str> :value11
-DOC
-STR

dotnet-yamldotnet-json

 error
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 5, Col: 1, Idx: 22) - (Line: 5, Col: 4, Idx: 25): Expected 'StreamEnd', got 'DocumentStart' (at Line: 5, Col: 1, Idx: 22).
   at YamlDotNet.Core.ParserExtensions.Require[T](IParser parser)
   at YamlDotNet.Core.ParserExtensions.Consume[T](IParser parser)
   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

 error
+STR
+DOC ---
=VAL &a1 <tag:yaml.org,2002:str> :scalar1
-DOC
+DOC ---
=VAL &a2 <tag:yaml.org,2002:str> :scalar2
-DOC
+DOC ---
=VAL &a3 <tag:yaml.org,2002:str> :scalar3
-DOC
+DOC ---
+MAP &a4 <tag:yaml.org,2002:map>
=VAL &a5 <tag:yaml.org,2002:str> :key5
=VAL :value4
-MAP
-DOC
+DOC ---
+MAP
=VAL :a6
=VAL :1
=VAL &anchor6 :b6
=VAL :2
-MAP
-DOC
+DOC ---
=VAL :
Parsing error near byte offset Pos {posByteOffset = 132, posCharOffset = 132, posLine = 19, posColumn = 0} (Lexical error near "!!map")

hs-hsyaml-json

 error
hsyaml-parser: user error (Lexical error near "!!map")

js-jsyaml-json

 error
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: duplication of an anchor property (14:1)

 11 | !!str scalar3
 12 | ---
 13 | &a4 !!map
 14 | &a5 !!str key5: value4
------^
 15 | ---
 16 | a6: 1
    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 readAnchorProperty (/node/node_modules/js-yaml/lib/loader.js:1317:5)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1407:38)
    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) {
  reason: 'duplication of an anchor property',
  mark: {
    name: null,
    buffer: '---\n' +
      '&a1\n' +
      '!!str\n' +
      'scalar1\n' +
      '---\n' +
      '!!str\n' +
      '&a2\n' +
      'scalar2\n' +
      '---\n' +
      '&a3\n' +
      '!!str scalar3\n' +
      '---\n' +
      '&a4 !!map\n' +
      '&a5 !!str key5: value4\n' +
      '---\n' +
      'a6: 1\n' +
      '&anchor6 b6: 2\n' +
      '---\n' +
      '!!map\n' +
      '&a8 !!str key8: value7\n' +
      '---\n' +
      '!!map\n' +
      '!!str &a10 key10: value9\n' +
      '---\n' +
      '!!str &a11\n' +
      'value11\n',
    position: 80,
    line: 13,
    column: 0,
    snippet: ' 11 | !!str scalar3\n' +
      ' 12 | ---\n' +
      ' 13 | &a4 !!map\n' +
      ' 14 | &a5 !!str key5: value4\n' +
      '------^\n' +
      ' 15 | ---\n' +
      ' 16 | a6: 1'
  }
}

Node.js v20.13.1

perl-syck-json

 error
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

 error
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-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 +DOC |
   1    0    0    0 =HEAD|---
   1    3    3    3 =EOL |\x0a
   2    0    4    4 +NODE|
   2    0    4    4 +PROP|
   2    0    4    4 +ANCH|
   2    0    4    4 =SYNX|&
   2    1    5    5 =META|a1
   2    3    7    7 -ANCH|
   2    3    7    7 =EOL |\x0a
   3    0    8    8 +TAG |
   3    0    8    8 +HAND|
   3    0    8    8 =SYNX|!
   3    1    9    9 =SYNX|!
   3    2   10   10 -HAND|
   3    2   10   10 =META|str
   3    5   13   13 -TAG |
   3    5   13   13 -PROP|
   3    5   13   13 =EOL |\x0a
   4    0   14   14 +VAL |
   4    0   14   14 =TEXT|scalar1
   4    7   21   21 -VAL |
   4    7   21   21 -NODE|
   4    7   21   21 =EOL |\x0a
   5    0   22   22 -DOC |
   5    0   22   22 +DOC |
   5    0   22   22 =HEAD|---
   5    3   25   25 =EOL |\x0a
   6    0   26   26 +NODE|
   6    0   26   26 +PROP|
   6    0   26   26 +TAG |
   6    0   26   26 +HAND|
   6    0   26   26 =SYNX|!
   6    1   27   27 =SYNX|!
   6    2   28   28 -HAND|
   6    2   28   28 =META|str
   6    5   31   31 -TAG |
   6    5   31   31 =EOL |\x0a
   7    0   32   32 +ANCH|
   7    0   32   32 =SYNX|&
   7    1   33   33 =META|a2
   7    3   35   35 -ANCH|
   7    3   35   35 -PROP|
   7    3   35   35 =EOL |\x0a
   8    0   36   36 +VAL |
   8    0   36   36 =TEXT|scalar2
   8    7   43   43 -VAL |
   8    7   43   43 -NODE|
   8    7   43   43 =EOL |\x0a
   9    0   44   44 -DOC |
   9    0   44   44 +DOC |
   9    0   44   44 =HEAD|---
   9    3   47   47 =EOL |\x0a
  10    0   48   48 +NODE|
  10    0   48   48 +PROP|
  10    0   48   48 +ANCH|
  10    0   48   48 =SYNX|&
  10    1   49   49 =META|a3
  10    3   51   51 -ANCH|
  10    3   51   51 =EOL |\x0a
  11    0   52   52 +TAG |
  11    0   52   52 +HAND|
  11    0   52   52 =SYNX|!
  11    1   53   53 =SYNX|!
  11    2   54   54 -HAND|
  11    2   54   54 =META|str
  11    5   57   57 -TAG |
  11    5   57   57 -PROP|
  11    5   57   57 =WSPC|.
  11    6   58   58 +VAL |
  11    6   58   58 =TEXT|scalar3
  11   13   65   65 -VAL |
  11   13   65   65 -NODE|
  11   13   65   65 =EOL |\x0a
  12    0   66   66 -DOC |
  12    0   66   66 +DOC |
  12    0   66   66 =HEAD|---
  12    3   69   69 +NODE|
  12    3   69   69 =EOL |\x0a
  13    0   70   70 +PROP|
  13    0   70   70 +ANCH|
  13    0   70   70 =SYNX|&
  13    1   71   71 =META|a4
  13    3   73   73 -ANCH|
  13    3   73   73 =WSPC|.
  13    4   74   74 +TAG |
  13    4   74   74 +HAND|
  13    4   74   74 =SYNX|!
  13    5   75   75 =SYNX|!
  13    6   76   76 -HAND|
  13    6   76   76 =META|map
  13    9   79   79 -TAG |
  13    9   79   79 -PROP|
  13    9   79   79 =EOL |\x0a
  14    0   80   80 +MAP |
  14    0   80   80 +PAIR|
  14    0   80   80 +NODE|
  14    0   80   80 +PROP|
  14    0   80   80 +ANCH|
  14    0   80   80 =SYNX|&
  14    1   81   81 =META|a5
  14    3   83   83 -ANCH|
  14    3   83   83 =WSPC|.
  14    4   84   84 +TAG |
  14    4   84   84 +HAND|
  14    4   84   84 =SYNX|!
  14    5   85   85 =SYNX|!
  14    6   86   86 -HAND|
  14    6   86   86 =META|str
  14    9   89   89 -TAG |
  14    9   89   89 -PROP|
  14    9   89   89 =WSPC|.
  14   10   90   90 +VAL |
  14   10   90   90 =TEXT|key5
  14   14   94   94 -VAL |
  14   14   94   94 -NODE|
  14   14   94   94 =SYNX|:
  14   15   95   95 =WSPC|.
  14   16   96   96 +NODE|
  14   16   96   96 +VAL |
  14   16   96   96 =TEXT|value4
  14   22  102  102 -VAL |
  14   22  102  102 -NODE|
  14   22  102  102 =EOL |\x0a
  15    0  103  103 -PAIR|
  15    0  103  103 -MAP |
  15    0  103  103 -NODE|
  15    0  103  103 -DOC |
  15    0  103  103 +DOC |
  15    0  103  103 =HEAD|---
  15    3  106  106 +NODE|
  15    3  106  106 =EOL |\x0a
  16    0  107  107 +MAP |
  16    0  107  107 +PAIR|
  16    0  107  107 +NODE|
  16    0  107  107 +VAL |
  16    0  107  107 =TEXT|a6
  16    2  109  109 -VAL |
  16    2  109  109 -NODE|
  16    2  109  109 =SYNX|:
  16    3  110  110 =WSPC|.
  16    4  111  111 +NODE|
  16    4  111  111 +VAL |
  16    4  111  111 =TEXT|1
  16    5  112  112 -VAL |
  16    5  112  112 -NODE|
  16    5  112  112 =EOL |\x0a
  17    0  113  113 -PAIR|
  17    0  113  113 +PAIR|
  17    0  113  113 +NODE|
  17    0  113  113 +PROP|
  17    0  113  113 +ANCH|
  17    0  113  113 =SYNX|&
  17    1  114  114 =META|anchor6
  17    8  121  121 -ANCH|
  17    8  121  121 -PROP|
  17    8  121  121 =WSPC|.
  17    9  122  122 +VAL |
  17    9  122  122 =TEXT|b6
  17   11  124  124 -VAL |
  17   11  124  124 -NODE|
  17   11  124  124 =SYNX|:
  17   12  125  125 =WSPC|.
  17   13  126  126 +NODE|
  17   13  126  126 +VAL |
  17   13  126  126 =TEXT|2
  17   14  127  127 -VAL |
  17   14  127  127 -NODE|
  17   14  127  127 =EOL |\x0a
  18    0  128  128 -PAIR|
  18    0  128  128 -MAP |
  18    0  128  128 -NODE|
  18    0  128  128 -DOC |
  18    0  128  128 +DOC |
  18    0  128  128 =HEAD|---
  18    3  131  131 +NODE|
  18    3  131  131 +VAL |
  18    3  131  131 -VAL |
  18    3  131  131 -NODE|
  18    3  131  131 =EOL |\x0a
  19    0  132  132 =REST|!!map
  19    5  137  137 =REST|\x0a
  20    0  138  138 =REST|&a8.!!str.key8:.value7
  20   22  160  160 =REST|\x0a
  21    0  161  161 -DOC |
  21    0  161  161 +DOC |
  21    0  161  161 =HEAD|---
  21    3  164  164 +NODE|
  21    3  164  164 =EOL |\x0a
  22    0  165  165 +PROP|
  22    0  165  165 +TAG |
  22    0  165  165 +HAND|
  22    0  165  165 =SYNX|!
  22    1  166  166 =SYNX|!
  22    2  167  167 -HAND|
  22    2  167  167 =META|map
  22    5  170  170 -TAG |
  22    5  170  170 -PROP|
  22    5  170  170 =EOL |\x0a
  23    0  171  171 +MAP |
----- 8< -----

perl-pp-perl

 na
'scalar1'
'scalar2'
'scalar3'
{
  'key5' => 'value4'
}
{
  'a6' => 1,
  'b6' => 2
}
{
  'key8' => 'value7'
}
{
  'key10' => 'value9'
}
'value11'

perl-pplibyaml-perl

 na
'scalar1'
'scalar2'
'scalar3'
{
  'key5' => 'value4'
}
{
  'a6' => 1,
  'b6' => 2
}
{
  'key8' => 'value7'
}
{
  'key10' => 'value9'
}
'value11'

perl-xs-perl

 na
'scalar1'
'scalar2'
'scalar3'
{
  'key5' => 'value4'
}
{
  'a6' => 1,
  'b6' => 2
}
{
  'key8' => 'value7'
}
{
  'key10' => 'value9'
}
'value11'

py-pyyaml-py

 na
'scalar1'
'scalar2'
'scalar3'
{'key5': 'value4'}
{'a6': 1, 'b6': 2}
{'key8': 'value7'}
{'key10': 'value9'}
'value11'

py-ruamel-py

 na
'scalar1'
'scalar2'
'scalar3'
{'key5': 'value4'}
{'a6': 1, 'b6': 2}
{'key8': 'value7'}
{'key10': 'value9'}
'value11'

perl-tiny-json

 ni
YAML::Tiny failed to classify line '&a1' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 ni
YAML::Tiny failed to classify line '&a1' at /yaml/bin/perl-tiny-perl line 15.