# YAML Test Matrix

--- &test-SBG9
  Title: Flow Sequence in Flow Mapping
  Tags: [ complex-key, flow, mapping, sequence ]

YAML

{a: [b, c], [d, e]: f}

Expected Events

+STR
+DOC
+MAP {}
=VAL :a
+SEQ []
=VAL :b
=VAL :c
-SEQ
+SEQ []
=VAL :d
=VAL :e
-SEQ
=VAL :f
-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-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: [b, c], [d, e]: f}
    ^
found unhashable key
  in "<unicode string>", line 1, column 13:
    {a: [b, c], [d, e]: f}
                ^

c-libfyaml-json

 na
{
  "a": [
    "b",
    "c"
  ],
stdin:1:13: error: Non scalar keys are not allowed in JSON emit mode
{a: [b, c], [d, e]: f}
            ^~~~~~

dotnet-yamldotnet-json

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

hs-hsyaml-json

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

java-snakeyaml-json

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

js-jsyaml-json

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

js-yaml-json

 na
{
  "a": [
    "b",
    "c"
  ],
  "[ d, e ]": "f"
}
(node:2930) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ d, e ]". 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 0x5610bfa1bf97

perl-pp-json

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

perl-pp-perl

 na
{
  '[\'d\',\'e\']' => 'f',
  'a' => [
           'b',
           'c'
         ]
}

perl-pplibyaml-json

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

perl-pplibyaml-perl

 na
{
  '[\'d\',\'e\']' => 'f',
  'a' => [
           'b',
           'c'
         ]
}

perl-syck-json

 na
{
   "ARRAY(0x555cd1ec4b58)" : "f",
   "a" : [
      "b",
      "c"
   ]
}

perl-syck-perl

 na
{
  'ARRAY(0x55e2d65a0918)' => 'f',
  'a' => [
           'b',
           'c'
         ]
}

perl-tiny-json

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

perl-xs-json

 na
{
   "ARRAY(0x561fe9154920)" : "f",
   "a" : [
      "b",
      "c"
   ]
}

perl-xs-perl

 na
{
  'ARRAY(0x55e2af2db280)' => 'f',
  'a' => [
           'b',
           'c'
         ]
}

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

py-ruamel-json

 na
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 21, in <module>
    print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 353, in _iterencode_dict
    items = sorted(dct.items(), key=lambda kv: kv[0])
TypeError: '<' not supported between instances of 'tuple' and 'str'

py-ruamel-py

 na
{'a': ['b', 'c'], ('d', 'e'): 'f'}

ruby-psych-json

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

perl-tiny-perl

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