# YAML Test Matrix

--- &test-X38W
  Title: Aliases in Flow Objects
  Tags: [ alias, complex-key, flow ]

YAML

{ &a [a, &b b]: *b, *a : [c, *b, d]}

Expected Events

+STR
+DOC
+MAP {}
+SEQ [] &a
=VAL :a
=VAL &b :b
-SEQ
=ALI *b
=ALI *a
+SEQ []
=VAL :c
=ALI *b
=VAL :d
-SEQ
-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-pp-event

 ok

perl-pplibyaml-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

perl-pp-perl

 error
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.
 at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pplibyaml-perl

 error
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.

perl-yaml-perl

 error
YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 1
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 360.

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 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^
found unhashable key
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^

py-ruamel-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-py", line 36, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/main.py", line 976, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 106, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 123, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^ (line: 1)
found duplicate key "('a', 'b')" with value "[]" (original value: "b")
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^ (line: 1)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

Duplicate keys will become an error in future releases, and are errors
by default when using the new API.

c-libfyaml-json

 na
stdin:1:1: error: duplicate key after resolving
{ &a [a, &b b]: *b, *a : [c, *b, d]}
^

dotnet-yamldotnet-json

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

hs-hsyaml-json

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

java-snakeyaml-json

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

js-jsyaml-json

 na
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: duplicated mapping key (1:21)

 1 | { &a [a, &b b]: *b, *a : [c, *b, d]}
-------------------------^
    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 storeMappingPair (/node/node_modules/js-yaml/lib/loader.js:358:7)
    at readFlowCollection (/node/node_modules/js-yaml/lib/loader.js:796:7)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1442:11)
    at readBlockMapping (/node/node_modules/js-yaml/lib/loader.js:1104:12)
    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)

js-yaml-json

 na
{
  "[ a, &b b ]": "b",
  "*a": [
    "c",
    "b",
    "d"
  ]
}
(node:3284) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ a, &b b ]". Set mapAsMap: true to use object keys.

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 0x55d089c9cf97

perl-pp-json

 na
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.
 at /perl5/lib/perl5/YAML/PP/Loader.pm line 94.

perl-pplibyaml-json

 na
Duplicate key '['a','b']' at /perl5/lib/perl5/YAML/PP/Parser.pm line 61.

perl-syck-json

 na
{
   "ARRAY(0x5647b898f0f0)" : [
      "c",
      "b",
      "d"
   ]
}

perl-syck-perl

 na
{
  'ARRAY(0x56098fe4a118)' => [
                               'c',
                               'b',
                               'd'
                             ]
}

perl-tiny-json

 na
YAML::Tiny found illegal characters in plain scalar: '*b, *a : [c, *b, d]}' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
{
   "ARRAY(0x55a2df083968)" : [
      "c",
      "b",
      "d"
   ]
}

perl-xs-perl

 na
{
  'ARRAY(0x555f4c889b30)' => [
                               'c',
                               'b',
                               'd'
                             ]
}

perl-yaml-json

 na
YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 1
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 360.

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 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^
found unhashable key
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^

py-ruamel-json

 na
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 19, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/main.py", line 976, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 106, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 123, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 1, column 1:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
    ^ (line: 1)
found duplicate key "('a', 'b')" with value "[]" (original value: "b")
  in "<unicode string>", line 1, column 3:
    { &a [a, &b b]: *b, *a : [c, *b, d]}
      ^ (line: 1)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

Duplicate keys will become an error in future releases, and are errors
by default when using the new API.

ruby-psych-json

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

perl-tiny-perl

 ni
YAML::Tiny found illegal characters in plain scalar: '*b, *a : [c, *b, d]}' at /yaml/bin/perl-tiny-perl line 15.