# 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

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

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
{
  "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< -----

java-snakeengine-json

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

java-snakeyaml-json

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

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:2769) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ a ]". 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 0x55d03a7abf97

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(0x55e719098450)" : null
   },
   "complex2" : {
      "ARRAY(0x55e71908ae68)" : "b"
   },
   "complex3" : {
      "ARRAY(0x55e7190985e8)" : "b\n"
   },
   "complex4" : {
      "a\n" : null
   },
   "complex5" : {
      "ARRAY(0x55e7190984c8)" : [
         "b"
      ]
   }
}

perl-xs-perl

 na
{
  'complex1' => {
                  'ARRAY(0x555719232b40)' => undef
                },
  'complex2' => {
                  'ARRAY(0x555719233140)' => 'b'
                },
  'complex3' => {
                  'ARRAY(0x5557194c0d68)' => 'b
'
                },
  'complex4' => {
                  'a
' => undef
                },
  'complex5' => {
                  'ARRAY(0x5557194c0b10)' => [
                                               '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.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 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']}}

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
{"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.