# 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

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
=VAL :a
+SEQ
=VAL :b
=VAL :c
-SEQ
+SEQ
=VAL :d
=VAL :e
-SEQ
=VAL :f
-MAP
-DOC
-STR
Transformed Events:
+STR
+DOC
+MAP
=VAL :a
+SEQ
=VAL :b
=VAL :c
-SEQ
=VAL :[d
=VAL :
=VAL :e]
=VAL :f
-MAP
-DOC
-STR
Got Events:
+STR
+DOC
+MAP
=VAL :a
+SEQ
=VAL :b
=VAL :c
-SEQ
=VAL :[d
=VAL :
=VAL :e]
=VAL :f
-MAP
-DOC
-STR

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.12/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
          ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 141, in construct_mapping
    raise ConstructorError("while constructing a mapping", 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"}

go-yaml-json

 na
yaml: invalid map key: []interface {}{"d", "e"}

hs-hsyaml-json

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

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 +PAIR|
   1    1    1    1 +NODE|
   1    1    1    1 +VAL |
   1    1    1    1 =TEXT|a
   1    2    2    2 -VAL |
   1    2    2    2 -NODE|
   1    2    2    2 =SYNX|:
   1    3    3    3 =WSPC|.
   1    4    4    4 +NODE|
   1    4    4    4 +SEQ |
   1    4    4    4 =SYNX|[
   1    5    5    5 +NODE|
   1    5    5    5 +VAL |
   1    5    5    5 =TEXT|b
   1    6    6    6 -VAL |
   1    6    6    6 -NODE|
   1    6    6    6 =SYNX|,
   1    7    7    7 =WSPC|.
   1    8    8    8 +NODE|
   1    8    8    8 +VAL |
   1    8    8    8 =TEXT|c
   1    9    9    9 -VAL |
   1    9    9    9 -NODE|
   1    9    9    9 =SYNX|]
   1   10   10   10 -SEQ |
   1   10   10   10 -NODE|
   1   10   10   10 -PAIR|
   1   10   10   10 =SYNX|,
   1   11   11   11 =WSPC|.
   1   12   12   12 +PAIR|
   1   12   12   12 +NODE|
   1   12   12   12 +SEQ |
   1   12   12   12 =SYNX|[
   1   13   13   13 +NODE|
   1   13   13   13 +VAL |
   1   13   13   13 =TEXT|d
   1   14   14   14 -VAL |
   1   14   14   14 -NODE|
   1   14   14   14 =SYNX|,
   1   15   15   15 =WSPC|.
   1   16   16   16 +NODE|
   1   16   16   16 +VAL |
   1   16   16   16 =TEXT|e
   1   17   17   17 -VAL |
   1   17   17   17 -NODE|
   1   17   17   17 =SYNX|]
   1   18   18   18 -SEQ |
   1   18   18   18 -NODE|
   1   18   18   18 =SYNX|:
   1   19   19   19 =WSPC|.
   1   20   20   20 +NODE|
   1   20   20   20 +VAL |
   1   20   20   20 =TEXT|f
   1   21   21   21 -VAL |
   1   21   21   21 -NODE|
   1   21   21   21 -PAIR|
   1   21   21   21 =SYNX|}
   1   22   22   22 -MAP |
   1   22   22   22 -NODE|
   1   22   22   22 =EOL |\x0a
   2    0   23   23 -DOC |

js-jsyaml-json

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

js-yaml-json

 na
{
  "a": [
    "b",
    "c"
  ],
  "[ d, e ]": "f"
}
(node:3582) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ d, e ]". Set mapAsMap: true to use object keys.
(Use `node --trace-warnings ...` to show where the warning was created)

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

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(0x7f4546a30088)" : "f",
   "a" : [
      "b",
      "c"
   ]
}

perl-syck-perl

 na
{
  'ARRAY(0x7f27f52d1878)' => '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(0x7f54ec4c1868)" : "f",
   "a" : [
      "b",
      "c"
   ]
}

perl-xs-perl

 na
{
  'ARRAY(0x7fe40480b6c8)' => '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.12/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
          ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 141, in construct_mapping
    raise ConstructorError("while constructing a mapping", 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 23, in <module>
    print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 432, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.12/json/encoder.py", line 354, in _iterencode_dict
    items = sorted(dct.items())
            ^^^^^^^^^^^^^^^^^^^
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.