# YAML Test Matrix

--- &test-U3XV
  Title: Node and Mapping Key Anchors
  Tags: [ 1.3-err, anchor, comment ]

YAML

---
top1: &node1
  &k1 key1: one
top2: &node2 # comment
  key2: two
top3:
  &k3 key3: three
top4:
  &node4
  &k4 key4: four
top5:
  &node5
  key5: five
top6: &val6
  six
top7:
  &val7 seven

Expected Events

+STR
+DOC ---
+MAP
=VAL :top1
+MAP &node1
=VAL &k1 :key1
=VAL :one
-MAP
=VAL :top2
+MAP &node2
=VAL :key2
=VAL :two
-MAP
=VAL :top3
+MAP
=VAL &k3 :key3
=VAL :three
-MAP
=VAL :top4
+MAP &node4
=VAL &k4 :key4
=VAL :four
-MAP
=VAL :top5
+MAP &node5
=VAL :key5
=VAL :five
-MAP
=VAL :top6
=VAL &val6 :six
=VAL :top7
=VAL &val7 :seven
-MAP
-DOC
-STR

Expected JSON

{
"top1": {
"key1": "one"
},
"top2": {
"key2": "two"
},
"top3": {
"key3": "three"
},
"top4": {
"key4": "four"
},
"top5": {
"key5": "five"
},
"top6": "six",
"top7": "seven"
}

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-event

 ok

java-snakeyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-pplibyaml-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

hs-hsyaml-json

 json_ok

java-snakeyaml-json

 json_ok

js-yaml-json

 json_ok

lua-lyaml-json

 json_ok

perl-pp-json

 json_ok

perl-pplibyaml-json

 json_ok

perl-syck-json

 json_ok

perl-xs-json

 json_ok

py-pyyaml-json

 json_ok

py-ruamel-json

 json_ok

ruby-psych-json

 json_ok

js-jsyaml-json

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

 1 | ---
 2 | top1: &node1
 3 |   &k1 key1: one
-------^
 4 | top2: &node2 # comment
 5 |   key2: two
    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 readBlockMapping (/node/node_modules/js-yaml/lib/loader.js:1164:11)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1441: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)

perl-yaml-json

 error
YAML Error: Inconsistent indentation level
   Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
   Line: 5
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 804.

perl-yaml-perl

 error
YAML Error: Inconsistent indentation level
   Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
   Line: 5
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 804.

perl-pp-perl

 na
{
  'top1' => {
              'key1' => 'one'
            },
  'top2' => {
              'key2' => 'two'
            },
  'top3' => {
              'key3' => 'three'
            },
  'top4' => {
              'key4' => 'four'
            },
  'top5' => {
              'key5' => 'five'
            },
  'top6' => 'six',
  'top7' => 'seven'
}

perl-pplibyaml-perl

 na
{
  'top1' => {
              'key1' => 'one'
            },
  'top2' => {
              'key2' => 'two'
            },
  'top3' => {
              'key3' => 'three'
            },
  'top4' => {
              'key4' => 'four'
            },
  'top5' => {
              'key5' => 'five'
            },
  'top6' => 'six',
  'top7' => 'seven'
}

perl-syck-perl

 na
{
  'top1' => {
              'key1' => 'one'
            },
  'top2' => {
              'key2' => 'two'
            },
  'top3' => {
              'key3' => 'three'
            },
  'top4' => {
              'key4' => 'four'
            },
  'top5' => {
              'key5' => 'five'
            },
  'top6' => 'six',
  'top7' => 'seven'
}

perl-xs-perl

 na
{
  'top1' => {
              'key1' => 'one'
            },
  'top2' => {
              'key2' => 'two'
            },
  'top3' => {
              'key3' => 'three'
            },
  'top4' => {
              'key4' => 'four'
            },
  'top5' => {
              'key5' => 'five'
            },
  'top6' => 'six',
  'top7' => 'seven'
}

py-pyyaml-py

 na
{'top1': {'key1': 'one'},
 'top2': {'key2': 'two'},
 'top3': {'key3': 'three'},
 'top4': {'key4': 'four'},
 'top5': {'key5': 'five'},
 'top6': 'six',
 'top7': 'seven'}

py-ruamel-py

 na
{'top1': {'key1': 'one'},
 'top2': {'key2': 'two'},
 'top3': {'key3': 'three'},
 'top4': {'key4': 'four'},
 'top5': {'key5': 'five'},
 'top6': 'six',
 'top7': 'seven'}

perl-tiny-json

 ni
YAML::Tiny does not support a feature in line '&node1' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 ni
YAML::Tiny does not support a feature in line '&node1' at /yaml/bin/perl-tiny-perl line 15.