# YAML Test Matrix

--- &test-6BFJ
  Title: Mapping, key and flow sequence item anchors
  Tags: [ anchor, complex-key, flow, mapping, sequence ]

YAML

---
&mapping
&key [ &item a, b, c ]: value

Expected Events

+STR
+DOC ---
+MAP &mapping
+SEQ &key
=VAL &item :a
=VAL :b
=VAL :c
-SEQ
=VAL :value
-MAP
-DOC
-STR

Expected JSON



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-pplibyaml-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

perl-pp-event

 error
+STR
+DOC ---
+SEQ &key
Line      : 3
Column    : 15
Message   : A node can only have one anchor
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 678
YAML      : ", b, c ]: value\n"
  at /yaml/bin/perl-pp-event line 25.

perl-pp-perl

 error
Line      : 3
Column    : 15
Message   : A node can only have one anchor
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 678
YAML      : ", b, c ]: value\n"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 92.

perl-syck-perl

 error
Syck parser (line 3, column 6): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

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.

py-pyyaml-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-py", line 36, in <module>
    for doc in yaml.load_all(sys.stdin.read(), Loader=yaml.FullLoader):
  File "/python/lib/python3.7/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 142, in construct_mapping
    "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 1:
    &mapping
    ^
found unhashable key
  in "<unicode string>", line 3, column 1:
    &key [ &item a, b, c ]: value
    ^

c-libfyaml-json

 na
{
stdin:3:6: error: Non scalar keys are not allowed in JSON emit mode
&key [ &item a, b, c ]: value
     ^~~~~~~~~~~~~~~~~

dotnet-yamldotnet-json

 na
{? ["a", "b", "c"] : "value"}

hs-hsyaml-json

 na
{"[\"a\",\"b\",\"c\"]":"value"}

java-snakeyaml-json

 na
{
  "[a, b, c]": "value"
}

js-jsyaml-json

 na
/node/node_modules/js-yaml/lib/js-yaml/loader.js:173
  throw generateError(state, message);
  ^
YAMLException: duplication of an anchor property at line 3, column 1:
    &key [ &item a, b, c ]: value
    ^
    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 readAnchorProperty (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1236:5)
    at composeNode (/node/node_modules/js-yaml/lib/js-yaml/loader.js:1325:38)
    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)

js-yaml-json

 na
{
  "[ &item a, b, c ]": "value"
}

lua-lyaml-json

 na
luajit: /yaml/bin/lua-lyaml-json:8: Cannot serialise table: table key must be a number or string
stack traceback:
	[C]: in function 'encode'
	/yaml/bin/lua-lyaml-json:8: in main chunk
	[C]: at 0x558cabbcaf97

perl-pp-json

 na
Line      : 3
Column    : 15
Message   : A node can only have one anchor
Where     : /perl5/lib/perl5/YAML/PP/Parser.pm line 678
YAML      : ", b, c ]: value\n"
  at /perl5/lib/perl5/YAML/PP/Loader.pm line 92.

perl-pplibyaml-json

 na
{
   "['a','b','c']" : "value"
}

perl-pplibyaml-perl

 na
{
  '[\'a\',\'b\',\'c\']' => 'value'
}

perl-syck-json

 na
Syck parser (line 3, column 6): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

perl-tiny-json

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

perl-xs-json

 na
{
   "ARRAY(0x5565d8ecf968)" : "value"
}

perl-xs-perl

 na
{
  'ARRAY(0x5557d8c48b50)' => 'value'
}

perl-yaml-json

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

py-pyyaml-json

 na
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-json", line 19, in <module>
    for doc in yaml.load_all(sys.stdin.read(), Loader=yaml.FullLoader):
  File "/python/lib/python3.7/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 142, in construct_mapping
    "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 1:
    &mapping
    ^
found unhashable key
  in "<unicode string>", line 3, column 1:
    &key [ &item a, b, c ]: value
    ^

py-ruamel-json

 na
{
  
}

py-ruamel-py

 na
{('a', 'b', 'c'): 'value'}

ruby-psych-json

 na
{"[\"a\", \"b\", \"c\"]":"value"}

perl-tiny-perl

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