# 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-snakeengine-event

 ok

java-snakeyaml-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

rust-yamlrust-event

 ok

cpp-rapidyaml-event

 diff
Minimal 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
Transformed Events:
+STR
+DOC
+MAP
=VAL &a :[a
=VAL :
=VAL &b :b]
=ALI *b
=ALI *a
+SEQ
=VAL :c
=ALI *b
=VAL :d
-SEQ
-MAP
-DOC
-STR
Got Events:
+STR
+DOC
+MAP
=VAL &a :[a
=VAL :
=VAL &b :b]
=ALI *b
=ALI *a
+SEQ
=VAL :c
=ALI *b
=VAL :d
-SEQ
-MAP
-DOC
-STR

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 93, 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 1097, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 114, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 131, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 674, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 445, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 263, 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 294, 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

raku-yamlish-raku

 error
Couldn't parse YAML
  in sub load-yamls at /raku/sources/44795C7AB0F35700F4CA9C3E2CC5C924EE4C608F (YAMLish) line 959
  in block <unit> at /yaml/bin/raku-yamlish-raku line 6

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"]}

go-yaml-json

 na
yaml: invalid map key: []interface {}{"a", "b"}

hs-hsyaml-json

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

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 +NODE|
   1    0    0    0 +MAP |
   1    0    0    0 =SYNX|{
   1    1    1    1 =WSPC|.
   1    2    2    2 +PAIR|
   1    2    2    2 +NODE|
   1    2    2    2 +PROP|
   1    2    2    2 +ANCH|
   1    2    2    2 =SYNX|&
   1    3    3    3 =META|a
   1    4    4    4 -ANCH|
   1    4    4    4 -PROP|
   1    4    4    4 +VAL |
   1    4    4    4 -VAL |
   1    4    4    4 -NODE|
   1    4    4    4 +NODE|
   1    4    4    4 +VAL |
   1    4    4    4 -VAL |
   1    4    4    4 -NODE|
   1    4    4    4 -PAIR|
   1    4    4    4 =WSPC|.
   1    5    5    5 -MAP |
   1    5    5    5 -NODE|
   1    5    5    5 =ERR |Unexpected.'['
   1    5    5    5 =REST|[a,.&b.b]:.*b,.*a.:.[c,.*b,.d]}
   1   36   36   36 =REST|\x0a
   2    0   37   37 -DOC |

java-snakeengine-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:4022) 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 0x5635fd3e3f97

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(0x5590eaf77f38)" : [
      "c",
      "b",
      "d"
   ]
}

perl-syck-perl

 na
{
  'ARRAY(0x55d1ca108068)' => [
                               '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(0x55e48323c438)" : [
      "c",
      "b",
      "d"
   ]
}

perl-xs-perl

 na
{
  'ARRAY(0x55ce59c44ab0)' => [
                               '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 93, 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 1097, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 114, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 131, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 674, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 445, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 263, 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 294, 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

raku-yamlish-json

 na
Couldn't parse YAML
  in sub load-yamls at /raku/sources/44795C7AB0F35700F4CA9C3E2CC5C924EE4C608F (YAMLish) line 959
  in block <unit> at /yaml/bin/raku-yamlish-json line 6

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.