# YAML Test Matrix

--- &test-RZP5
  Title: Various Trailing Comments [1.3]
  Tags: [ 1.3-mod, anchor, comment, folded, mapping ]

YAML

a: "double
  quotes" # lala
b: plain
 value  # lala
c  : #lala
  d
? # lala
 - seq1
: # lala
 - #lala
  seq2
e: &node # lala
 - x: y
block: > # lala
  abcde

Expected Events

+STR
+DOC
+MAP
=VAL :a
=VAL "double quotes
=VAL :b
=VAL :plain value
=VAL :c
=VAL :d
+SEQ
=VAL :seq1
-SEQ
+SEQ
=VAL :seq2
-SEQ
=VAL :e
+SEQ &node
+MAP
=VAL :x
=VAL :y
-MAP
-SEQ
=VAL :block
=VAL >abcde\n
-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

 error
-:8:1: (76B): ERROR: parse error - indentation should not increase at this point
-:8:1:  - seq1  (size=7)
       ^~~~~~~  (cols 1-8)

perl-yaml-perl

 error
YAML Error: Inconsistent indentation level
   Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
   Line: 2
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 804.

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: "double
    ^
found unhashable key
  in "<unicode string>", line 8, column 2:
     - seq1
     ^

c-libfyaml-json

 na
{
  "a": "double quotes",
  "b": "plain value",
  "c": "d",
stdin:8:2: error: Non scalar keys are not allowed in JSON emit mode
 - seq1
 ^~~~~~

dotnet-yamldotnet-json

 na
{"a": "double quotes", "b": "plain value", "c": "d", ? ["seq1"] : ["seq2"], "e": [{"x": "y"}], "block": "abcde\n"}

go-yaml-json

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

hs-hsyaml-json

 na
{"[\"seq1\"]":["seq2"],"a":"double quotes","b":"plain value","block":"abcde\n","c":"d","e":[{"x":"y"}]}

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|a
   1    1    1    1 -VAL |
   1    1    1    1 -NODE|
   1    1    1    1 =SYNX|:
   1    2    2    2 =WSPC|.
   1    3    3    3 +NODE|
   1    3    3    3 +VAL |
   1    3    3    3 =SYNX|"
   1    4    4    4 =TEXT|double
   1   10   10   10 =FOLD|\x0a
   2    0   11   11 =DENT|.
   2    1   12   12 =WSPC|.
   2    2   13   13 =TEXT|quotes
   2    8   19   19 =SYNX|"
   2    9   20   20 -VAL |
   2    9   20   20 -NODE|
   2    9   20   20 =WSPC|.
   2   10   21   21 +COMM|
   2   10   21   21 =SYNX|#
   2   11   22   22 =META|.lala
   2   16   27   27 -COMM|
   2   16   27   27 =EOL |\x0a
   3    0   28   28 -PAIR|
   3    0   28   28 +PAIR|
   3    0   28   28 +NODE|
   3    0   28   28 +VAL |
   3    0   28   28 =TEXT|b
   3    1   29   29 -VAL |
   3    1   29   29 -NODE|
   3    1   29   29 =SYNX|:
   3    2   30   30 =WSPC|.
   3    3   31   31 +NODE|
   3    3   31   31 +VAL |
   3    3   31   31 =TEXT|plain
   3    8   36   36 =FOLD|\x0a
   4    0   37   37 =DENT|.
   4    1   38   38 =TEXT|value
   4    6   43   43 -VAL |
   4    6   43   43 -NODE|
   4    6   43   43 =WSPC|..
   4    8   45   45 +COMM|
   4    8   45   45 =SYNX|#
   4    9   46   46 =META|.lala
   4   14   51   51 -COMM|
   4   14   51   51 =EOL |\x0a
   5    0   52   52 -PAIR|
   5    0   52   52 +PAIR|
   5    0   52   52 +NODE|
   5    0   52   52 +VAL |
   5    0   52   52 =TEXT|c
   5    1   53   53 -VAL |
   5    1   53   53 -NODE|
   5    1   53   53 =WSPC|..
   5    3   55   55 =SYNX|:
   5    4   56   56 =WSPC|.
   5    5   57   57 +COMM|
   5    5   57   57 =SYNX|#
   5    6   58   58 =META|lala
   5   10   62   62 -COMM|
   5   10   62   62 =EOL |\x0a
   6    0   63   63 =DENT|.
   6    1   64   64 =WSPC|.
   6    2   65   65 +NODE|
   6    2   65   65 +VAL |
   6    2   65   65 =TEXT|d
   6    3   66   66 -VAL |
   6    3   66   66 -NODE|
   6    3   66   66 =EOL |\x0a
   7    0   67   67 -PAIR|
   7    0   67   67 +PAIR|
   7    0   67   67 =SYNX|?
   7    1   68   68 +NODE|
   7    1   68   68 =WSPC|.
   7    2   69   69 +COMM|
   7    2   69   69 =SYNX|#
   7    3   70   70 =META|.lala
   7    8   75   75 -COMM|
   7    8   75   75 =EOL |\x0a
   8    0   76   76 +SEQ |
   8    0   76   76 =DENT|.
   8    1   77   77 =SYNX|-
   8    2   78   78 =WSPC|.
   8    3   79   79 +NODE|
   8    3   79   79 +VAL |
   8    3   79   79 =TEXT|seq1
   8    7   83   83 -VAL |
   8    7   83   83 -NODE|
   8    7   83   83 =EOL |\x0a
   9    0   84   84 -SEQ |
   9    0   84   84 -NODE|
   9    0   84   84 =SYNX|:
   9    1   85   85 +NODE|
   9    1   85   85 =WSPC|.
   9    2   86   86 +COMM|
   9    2   86   86 =SYNX|#
   9    3   87   87 =META|.lala
   9    8   92   92 -COMM|
   9    8   92   92 =EOL |\x0a
  10    0   93   93 +SEQ |
  10    0   93   93 =DENT|.
  10    1   94   94 =SYNX|-
  10    2   95   95 =WSPC|.
  10    3   96   96 +COMM|
  10    3   96   96 =SYNX|#
  10    4   97   97 =META|lala
  10    8  101  101 -COMM|
  10    8  101  101 =EOL |\x0a
  11    0  102  102 =DENT|..
  11    2  104  104 +NODE|
  11    2  104  104 +VAL |
  11    2  104  104 =TEXT|seq2
  11    6  108  108 -VAL |
  11    6  108  108 -NODE|
  11    6  108  108 =EOL |\x0a
  12    0  109  109 -SEQ |
  12    0  109  109 -NODE|
  12    0  109  109 -PAIR|
  12    0  109  109 +PAIR|
  12    0  109  109 +NODE|
  12    0  109  109 +VAL |
  12    0  109  109 =TEXT|e
  12    1  110  110 -VAL |
  12    1  110  110 -NODE|
  12    1  110  110 =SYNX|:
  12    2  111  111 +NODE|
  12    2  111  111 =WSPC|.
  12    3  112  112 +PROP|
  12    3  112  112 +ANCH|
  12    3  112  112 =SYNX|&
  12    4  113  113 =META|node
  12    8  117  117 -ANCH|
  12    8  117  117 -PROP|
  12    8  117  117 =WSPC|.
  12    9  118  118 +COMM|
  12    9  118  118 =SYNX|#
  12   10  119  119 =META|.lala
  12   15  124  124 -COMM|
  12   15  124  124 =EOL |\x0a
  13    0  125  125 +SEQ |
  13    0  125  125 =DENT|.
  13    1  126  126 =SYNX|-
  13    2  127  127 =DENT|.
  13    3  128  128 +NODE|
  13    3  128  128 +MAP |
  13    3  128  128 +PAIR|
  13    3  128  128 +NODE|
  13    3  128  128 +VAL |
  13    3  128  128 =TEXT|x
  13    4  129  129 -VAL |
  13    4  129  129 -NODE|
  13    4  129  129 =SYNX|:
  13    5  130  130 =WSPC|.
  13    6  131  131 +NODE|
  13    6  131  131 +VAL |
  13    6  131  131 =TEXT|y
  13    7  132  132 -VAL |
  13    7  132  132 -NODE|
  13    7  132  132 =EOL |\x0a
  14    0  133  133 -PAIR|
  14    0  133  133 -MAP |
  14    0  133  133 -NODE|
  14    0  133  133 -SEQ |
  14    0  133  133 -NODE|
  14    0  133  133 -PAIR|
  14    0  133  133 +PAIR|
  14    0  133  133 +NODE|
  14    0  133  133 +VAL |
  14    0  133  133 =TEXT|block
  14    5  138  138 -VAL |
  14    5  138  138 -NODE|
  14    5  138  138 =SYNX|:
  14    6  139  139 +NODE|
  14    6  139  139 =WSPC|.
  14    7  140  140 +VAL |
  14    7  140  140 =SYNX|>
  14    8  141  141 =WSPC|.
  14    9  142  142 +COMM|
  14    9  142  142 =SYNX|#
  14   10  143  143 =META|.lala
  14   15  148  148 -COMM|
  14   15  148  148 =EOL |\x0a
  15    0  149  149 =DENT|..
  15    2  151  151 =TEXT|abcde
  15    7  156  156 =NEWL|\x0a
  16    0  157  157 -VAL |
  16    0  157  157 -NODE|
  16    0  157  157 -PAIR|
  16    0  157  157 -MAP |
  16    0  157  157 -NODE|
  16    0  157  157 -DOC |

js-jsyaml-json

 na
{"a":"double quotes","b":"plain value","c":"d","seq1":["seq2"],"e":[{"x":"y"}],"block":"abcde\n"}

js-yaml-json

 na
{
  "a": "double quotes",
  "b": "plain value",
  "c": "d",
  "[ seq1 ]": [
    "seq2"
  ],
  "e": [
    {
      "x": "y"
    }
  ],
  "block": "abcde\n"
}
(node:3485) Warning: Keys with collection values will be stringified due to JS Object restrictions: "[ seq1 ]". 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 0x55e60ba27ed0

perl-pp-json

 na
{
   "['seq1']" : [
      "seq2"
   ],
   "a" : "double quotes",
   "b" : "plain value",
   "block" : "abcde\n",
   "c" : "d",
   "e" : [
      {
         "x" : "y"
      }
   ]
}

perl-pp-perl

 na
{
  '[\'seq1\']' => [
                    'seq2'
                  ],
  'a' => 'double quotes',
  'b' => 'plain value',
  'block' => 'abcde
',
  'c' => 'd',
  'e' => [
           {
             'x' => 'y'
           }
         ]
}

perl-pplibyaml-json

 na
{
   "['seq1']" : [
      "seq2"
   ],
   "a" : "double quotes",
   "b" : "plain value",
   "block" : "abcde\n",
   "c" : "d",
   "e" : [
      {
         "x" : "y"
      }
   ]
}

perl-pplibyaml-perl

 na
{
  '[\'seq1\']' => [
                    'seq2'
                  ],
  'a' => 'double quotes',
  'b' => 'plain value',
  'block' => 'abcde
',
  'c' => 'd',
  'e' => [
           {
             'x' => 'y'
           }
         ]
}

perl-syck-json

 na
{
   "ARRAY(0x7f5952fb7ca0)" : [
      "seq2"
   ],
   "a" : "double quotes",
   "b" : "plain value",
   "block" : "abcde\n",
   "c" : "d",
   "e" : [
      {
         "x" : true
      }
   ]
}

perl-syck-perl

 na
{
  'ARRAY(0x7f023918f8c0)' => [
                               'seq2'
                             ],
  'a' => 'double quotes',
  'b' => 'plain value',
  'block' => 'abcde
',
  'c' => 'd',
  'e' => [
           {
             'x' => !!1
           }
         ]
}

perl-tiny-json

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

perl-xs-json

 na
{
   "ARRAY(0x7ff1fa596860)" : [
      "seq2"
   ],
   "a" : "double quotes",
   "b" : "plain value",
   "block" : "abcde\n",
   "c" : "d",
   "e" : [
      {
         "x" : "y"
      }
   ]
}

perl-xs-perl

 na
{
  'ARRAY(0x7ff29e956698)' => [
                               'seq2'
                             ],
  'a' => 'double quotes',
  'b' => 'plain value',
  'block' => 'abcde
',
  'c' => 'd',
  'e' => [
           {
             'x' => 'y'
           }
         ]
}

perl-yaml-json

 na
YAML Error: Inconsistent indentation level
   Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
   Line: 2
   Document: 1
 at /perl5/lib/perl5/YAML/Loader.pm line 804.

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: "double
    ^
found unhashable key
  in "<unicode string>", line 8, column 2:
     - seq1
     ^

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': 'double quotes',
 'b': 'plain value',
 'block': 'abcde\n',
 'c': 'd',
 'e': [{'x': 'y'}],
 ('seq1',): ['seq2']}

ruby-psych-json

 na
{"a":"double quotes","b":"plain value","c":"d","[\"seq1\"]":["seq2"],"e":[{"x":"y"}],"block":"abcde\n"}

perl-tiny-perl

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