# YAML Test Matrix

--- &test-KK5P
  Title: Various combinations of explicit block mappings
  Tags: [ explicit-key, mapping, sequence ]

YAML

complex1:
  ? - a
complex2:
  ? - a
  : b
complex3:
  ? - a
  : >
    b
complex4:
  ? >
    a
  :
complex5:
  ? - a
  : - b

Expected Events

+STR
+DOC
+MAP
=VAL :complex1
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :
-MAP
=VAL :complex2
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :b
-MAP
=VAL :complex3
+MAP
+SEQ
=VAL :a
-SEQ
=VAL >b\n
-MAP
=VAL :complex4
+MAP
=VAL >a\n
=VAL :
-MAP
=VAL :complex5
+MAP
+SEQ
=VAL :a
-SEQ
+SEQ
=VAL :b
-SEQ
-MAP
-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 :complex1
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :
-MAP
=VAL :complex2
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :b
-MAP
=VAL :complex3
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :b\n
-MAP
=VAL :complex4
+MAP
=VAL :a\n
=VAL :
-MAP
=VAL :complex5
+MAP
+SEQ
=VAL :a
-SEQ
+SEQ
=VAL :b
-SEQ
-MAP
-MAP
-DOC
-STR
Transformed Events:
+STR
+DOC
+MAP
=VAL :complex1
+MAP
-MAP
=VAL :complex2
+MAP
=VAL :- a
=VAL :b
-MAP
=VAL :complex3
+MAP
=VAL :- a
=VAL :b\n
-MAP
=VAL :complex4
+MAP
=VAL :a\n
=VAL :
-MAP
=VAL :complex5
+MAP
=VAL :- a
+SEQ
=VAL :b
-SEQ
-MAP
-MAP
-DOC
-STR
Got Events:
+STR
+DOC
+MAP
=VAL :complex1
+MAP
-MAP
=VAL :complex2
+MAP
=VAL :- a
=VAL :b
-MAP
=VAL :complex3
+MAP
=VAL :- a
=VAL 'b\n
-MAP
=VAL :complex4
+MAP
=VAL 'a\n
=VAL :
-MAP
=VAL :complex5
+MAP
=VAL :- a
+SEQ
=VAL :b
-SEQ
-MAP
-MAP
-DOC
-STR

perl-syck-perl

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

perl-yaml-perl

 error
YAML Error: Unrecognized implicit value '- a'
   Code: YAML_PARSE_ERR_BAD_IMPLICIT
   Line: 3
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 624.

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 2, column 3:
      ? - a
      ^
found unhashable key
  in "<unicode string>", line 2, column 5:
      ? - a
        ^

c-libfyaml-json

 na
{
  "complex1": {,
  "complex2": {,
  "complex3": {,
  "complex4": {
    "a\n": null
  },
  "complex5": {
}
stdin:2:5: error: Non scalar keys are not allowed in JSON emit mode
  ? - a
    ^~~
stdin:4:5: error: Non scalar keys are not allowed in JSON emit mode
  ? - a
    ^~~
  : b
~~
stdin:7:5: error: Non scalar keys are not allowed in JSON emit mode
  ? - a
    ^~~
  : >
~~
stdin:15:5: error: Non scalar keys are not allowed in JSON emit mode
  ? - a
    ^~~
  : - b
~~

dotnet-yamldotnet-json

 na
{"complex1": {? ["a"] : null}, "complex2": {? ["a"] : "b"}, "complex3": {? ["a"] : "b\n"}, "complex4": {? "a\n" : null}, "complex5": {? ["a"] : ["b"]}}

go-yaml-json

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

hs-hsyaml-json

 na
{"complex1":{"[\"a\"]":null},"complex2":{"[\"a\"]":"b"},"complex3":{"[\"a\"]":"b\n"},"complex4":{"a\n":null},"complex5":{"[\"a\"]":["b"]}}

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 +PAIR|
   1    0    0    0 +NODE|
   1    0    0    0 +VAL |
   1    0    0    0 =TEXT|complex1
   1    8    8    8 -VAL |
   1    8    8    8 -NODE|
   1    8    8    8 =SYNX|:
   1    9    9    9 +NODE|
   1    9    9    9 =EOL |\x0a
   2    0   10   10 +MAP |
   2    0   10   10 =DENT|..
   2    2   12   12 +PAIR|
   2    2   12   12 =SYNX|?
   2    3   13   13 =DENT|.
   2    4   14   14 +NODE|
   2    4   14   14 +SEQ |
   2    4   14   14 =SYNX|-
   2    5   15   15 =WSPC|.
   2    6   16   16 +NODE|
   2    6   16   16 +VAL |
   2    6   16   16 =TEXT|a
   2    7   17   17 -VAL |
   2    7   17   17 -NODE|
   2    7   17   17 =EOL |\x0a
   3    0   18   18 -SEQ |
   3    0   18   18 -NODE|
   3    0   18   18 +NODE|
   3    0   18   18 +VAL |
   3    0   18   18 -VAL |
   3    0   18   18 -NODE|
   3    0   18   18 -PAIR|
   3    0   18   18 -MAP |
   3    0   18   18 -NODE|
   3    0   18   18 -PAIR|
   3    0   18   18 +PAIR|
   3    0   18   18 +NODE|
   3    0   18   18 +VAL |
   3    0   18   18 =TEXT|complex2
   3    8   26   26 -VAL |
   3    8   26   26 -NODE|
   3    8   26   26 =SYNX|:
   3    9   27   27 +NODE|
   3    9   27   27 =EOL |\x0a
   4    0   28   28 +MAP |
   4    0   28   28 =DENT|..
   4    2   30   30 +PAIR|
   4    2   30   30 =SYNX|?
   4    3   31   31 =DENT|.
   4    4   32   32 +NODE|
   4    4   32   32 +SEQ |
   4    4   32   32 =SYNX|-
   4    5   33   33 =WSPC|.
   4    6   34   34 +NODE|
   4    6   34   34 +VAL |
   4    6   34   34 =TEXT|a
   4    7   35   35 -VAL |
   4    7   35   35 -NODE|
   4    7   35   35 =EOL |\x0a
   5    0   36   36 -SEQ |
   5    0   36   36 -NODE|
   5    0   36   36 =DENT|..
   5    2   38   38 =SYNX|:
   5    3   39   39 =WSPC|.
   5    4   40   40 +NODE|
   5    4   40   40 +VAL |
   5    4   40   40 =TEXT|b
   5    5   41   41 -VAL |
   5    5   41   41 -NODE|
   5    5   41   41 =EOL |\x0a
   6    0   42   42 -PAIR|
   6    0   42   42 -MAP |
   6    0   42   42 -NODE|
   6    0   42   42 -PAIR|
   6    0   42   42 +PAIR|
   6    0   42   42 +NODE|
   6    0   42   42 +VAL |
   6    0   42   42 =TEXT|complex3
   6    8   50   50 -VAL |
   6    8   50   50 -NODE|
   6    8   50   50 =SYNX|:
   6    9   51   51 +NODE|
   6    9   51   51 =EOL |\x0a
   7    0   52   52 +MAP |
   7    0   52   52 =DENT|..
   7    2   54   54 +PAIR|
   7    2   54   54 =SYNX|?
   7    3   55   55 =DENT|.
   7    4   56   56 +NODE|
   7    4   56   56 +SEQ |
   7    4   56   56 =SYNX|-
   7    5   57   57 =WSPC|.
   7    6   58   58 +NODE|
   7    6   58   58 +VAL |
   7    6   58   58 =TEXT|a
   7    7   59   59 -VAL |
   7    7   59   59 -NODE|
   7    7   59   59 =EOL |\x0a
   8    0   60   60 -SEQ |
   8    0   60   60 -NODE|
   8    0   60   60 =DENT|..
   8    2   62   62 =SYNX|:
   8    3   63   63 +NODE|
   8    3   63   63 =WSPC|.
   8    4   64   64 +VAL |
   8    4   64   64 =SYNX|>
   8    5   65   65 =EOL |\x0a
   9    0   66   66 =DENT|....
   9    4   70   70 =TEXT|b
   9    5   71   71 =NEWL|\x0a
  10    0   72   72 -VAL |
  10    0   72   72 -NODE|
  10    0   72   72 -PAIR|
  10    0   72   72 -MAP |
  10    0   72   72 -NODE|
  10    0   72   72 -PAIR|
  10    0   72   72 +PAIR|
  10    0   72   72 +NODE|
  10    0   72   72 +VAL |
  10    0   72   72 =TEXT|complex4
  10    8   80   80 -VAL |
  10    8   80   80 -NODE|
  10    8   80   80 =SYNX|:
  10    9   81   81 +NODE|
  10    9   81   81 =EOL |\x0a
  11    0   82   82 +MAP |
  11    0   82   82 =DENT|..
  11    2   84   84 +PAIR|
  11    2   84   84 =SYNX|?
  11    3   85   85 +NODE|
  11    3   85   85 =WSPC|.
  11    4   86   86 +VAL |
  11    4   86   86 =SYNX|>
  11    5   87   87 =EOL |\x0a
  12    0   88   88 =DENT|....
  12    4   92   92 =TEXT|a
  12    5   93   93 =NEWL|\x0a
  13    0   94   94 -VAL |
  13    0   94   94 -NODE|
  13    0   94   94 =DENT|..
  13    2   96   96 =SYNX|:
  13    3   97   97 +NODE|
  13    3   97   97 +VAL |
  13    3   97   97 -VAL |
  13    3   97   97 -NODE|
  13    3   97   97 =EOL |\x0a
  14    0   98   98 -PAIR|
  14    0   98   98 -MAP |
  14    0   98   98 -NODE|
  14    0   98   98 -PAIR|
  14    0   98   98 +PAIR|
  14    0   98   98 +NODE|
  14    0   98   98 +VAL |
  14    0   98   98 =TEXT|complex5
  14    8  106  106 -VAL |
  14    8  106  106 -NODE|
  14    8  106  106 =SYNX|:
  14    9  107  107 +NODE|
  14    9  107  107 =EOL |\x0a
  15    0  108  108 +MAP |
  15    0  108  108 =DENT|..
  15    2  110  110 +PAIR|
  15    2  110  110 =SYNX|?
  15    3  111  111 =DENT|.
  15    4  112  112 +NODE|
  15    4  112  112 +SEQ |
  15    4  112  112 =SYNX|-
  15    5  113  113 =WSPC|.
  15    6  114  114 +NODE|
  15    6  114  114 +VAL |
  15    6  114  114 =TEXT|a
  15    7  115  115 -VAL |
  15    7  115  115 -NODE|
  15    7  115  115 =EOL |\x0a
  16    0  116  116 -SEQ |
  16    0  116  116 -NODE|
  16    0  116  116 =DENT|..
  16    2  118  118 =SYNX|:
  16    3  119  119 =DENT|.
  16    4  120  120 +NODE|
  16    4  120  120 +SEQ |
  16    4  120  120 =SYNX|-
  16    5  121  121 =WSPC|.
  16    6  122  122 +NODE|
  16    6  122  122 +VAL |
  16    6  122  122 =TEXT|b
  16    7  123  123 -VAL |
  16    7  123  123 -NODE|
  16    7  123  123 =EOL |\x0a
  17    0  124  124 -SEQ |
  17    0  124  124 -NODE|
  17    0  124  124 -PAIR|
  17    0  124  124 -MAP |
  17    0  124  124 -NODE|
  17    0  124  124 -PAIR|
  17    0  124  124 -MAP |
  17    0  124  124 -NODE|
  17    0  124  124 -DOC |
----- 8< -----

js-jsyaml-json

 na
{"complex1":{"a":null},"complex2":{"a":"b"},"complex3":{"a":"b\n"},"complex4":{"a\n":null},"complex5":{"a":["b"]}}

js-yaml-json

 na
{
  "complex1": {
    "[ a ]": null
  },
  "complex2": {
    "[ a ]": "b"
  },
  "complex3": {
    "[ a ]": "b\n"
  },
  "complex4": {
    "a\n": null
  },
  "complex5": {
    "[ a ]": [
      "b"
    ]
  }
}
(node:2771) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ a ]". 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 0x557174bffed0

perl-pp-json

 na
{
   "complex1" : {
      "['a']" : null
   },
   "complex2" : {
      "['a']" : "b"
   },
   "complex3" : {
      "['a']" : "b\n"
   },
   "complex4" : {
      "a\n" : null
   },
   "complex5" : {
      "['a']" : [
         "b"
      ]
   }
}

perl-pp-perl

 na
{
  'complex1' => {
                  '[\'a\']' => undef
                },
  'complex2' => {
                  '[\'a\']' => 'b'
                },
  'complex3' => {
                  '[\'a\']' => 'b
'
                },
  'complex4' => {
                  'a
' => undef
                },
  'complex5' => {
                  '[\'a\']' => [
                                 'b'
                               ]
                }
}

perl-pplibyaml-json

 na
{
   "complex1" : {
      "['a']" : null
   },
   "complex2" : {
      "['a']" : "b"
   },
   "complex3" : {
      "['a']" : "b\n"
   },
   "complex4" : {
      "a\n" : null
   },
   "complex5" : {
      "['a']" : [
         "b"
      ]
   }
}

perl-pplibyaml-perl

 na
{
  'complex1' => {
                  '[\'a\']' => undef
                },
  'complex2' => {
                  '[\'a\']' => 'b'
                },
  'complex3' => {
                  '[\'a\']' => 'b
'
                },
  'complex4' => {
                  'a
' => undef
                },
  'complex5' => {
                  '[\'a\']' => [
                                 'b'
                               ]
                }
}

perl-syck-json

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

perl-tiny-json

 na
YAML::Tiny does not support a feature in line '  ? - a' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
{
   "complex1" : {
      "ARRAY(0x7f0123ec98e0)" : null
   },
   "complex2" : {
      "ARRAY(0x7f0123e9f818)" : "b"
   },
   "complex3" : {
      "ARRAY(0x7f0123ec9c40)" : "b\n"
   },
   "complex4" : {
      "a\n" : null
   },
   "complex5" : {
      "ARRAY(0x7f0123ec9a90)" : [
         "b"
      ]
   }
}

perl-xs-perl

 na
{
  'complex1' => {
                  'ARRAY(0x7f009cde3560)' => undef
                },
  'complex2' => {
                  'ARRAY(0x7f009cde3ba8)' => 'b'
                },
  'complex3' => {
                  'ARRAY(0x7f009cdc08c0)' => 'b
'
                },
  'complex4' => {
                  'a
' => undef
                },
  'complex5' => {
                  'ARRAY(0x7f009caf5478)' => [
                                               'b'
                                             ]
                }
}

perl-yaml-json

 na
YAML Error: Unrecognized implicit value '- a'
   Code: YAML_PARSE_ERR_BAD_IMPLICIT
   Line: 3
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 624.

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 2, column 3:
      ? - a
      ^
found unhashable key
  in "<unicode string>", line 2, column 5:
      ? - a
        ^

py-ruamel-json

 na
{
  "complex1": {
    
  },
  "complex2": {
    
  },
  "complex3": {
    
  },
  "complex4": {
    "a\n": null
  },
  "complex5": {
    
  }
}

py-ruamel-py

 na
{'complex1': {('a',): None},
 'complex2': {('a',): 'b'},
 'complex3': {('a',): 'b\n'},
 'complex4': {'a\n': None},
 'complex5': {('a',): ['b']}}

ruby-psych-json

 na
{"complex1":{"[\"a\"]":null},"complex2":{"[\"a\"]":"b"},"complex3":{"[\"a\"]":"b\n"},"complex4":{"a\n":null},"complex5":{"[\"a\"]":["b"]}}

perl-tiny-perl

 ni
YAML::Tiny does not support a feature in line '  ? - a' at /yaml/bin/perl-tiny-perl line 15.