# YAML Test Matrix

--- &test-6HB6
  Title: Spec Example 6.1. Indentation Spaces
  Tags: [ comment, flow, indent, spec, upto-1.2, whitespace ]

YAML

  # Leading comment line spaces are
   # neither content nor indentation.
    
Not indented:
 By one space: |
    By four
      spaces
 Flow style: [    # Leading spaces
   By two,        # in flow style
  Also by two,    # are neither
  	Still by two   # content nor
    ]             # indentation.

Expected Events

+STR
+DOC
+MAP
=VAL :Not indented
+MAP
=VAL :By one space
=VAL |By four\n  spaces\n
=VAL :Flow style
+SEQ []
=VAL :By two
=VAL :Also by two
=VAL :Still by two
-SEQ
-MAP
-MAP
-DOC
-STR

Expected JSON

{
"Not indented": {
"By one space": "By four\n spaces\n",
"Flow style": [
"By two",
"Also by two",
"Still by two"
]
}
}

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-rapidyaml-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-ruamel-event

 ok

rust-yamlrust-event

 ok

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

go-yaml-json

 json_ok

hs-hsyaml-json

 json_ok

js-jsyaml-json

 json_ok

js-yaml-json

 json_ok

lua-lyaml-json

 json_ok

perl-pp-json

 json_ok

perl-pplibyaml-json

 json_ok

perl-syck-json

 json_ok

perl-xs-json

 json_ok

py-ruamel-json

 json_ok

ruby-psych-json

 json_ok

perl-yaml-json

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

perl-yaml-perl

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

py-pyyaml-event

 error
+STR
+DOC
+MAP
=VAL :Not indented
+MAP
=VAL :By one space
=VAL |By four\n  spaces\n
=VAL :Flow style
+SEQ []
=VAL :By two
=VAL :Also by two
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-event", line 7, in <module>
    for event in yaml.parse(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/yaml/__init__.py", line 75, in parse
    while loader.check_event():
          ^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 486, in parse_flow_sequence_entry
    if self.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 258, in fetch_more_tokens
    raise ScannerError("while scanning for the next token", None,
yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
  in "<unicode string>", line 11, column 3:
      	Still by two   # content nor
      ^

py-pyyaml-json

 error
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/composer.py", line 27, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 486, in parse_flow_sequence_entry
    if self.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 258, in fetch_more_tokens
    raise ScannerError("while scanning for the next token", None,
yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
  in "<unicode string>", line 11, column 3:
      	Still by two   # content nor
      ^

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/composer.py", line 27, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 486, in parse_flow_sequence_entry
    if self.check_token(KeyToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 258, in fetch_more_tokens
    raise ScannerError("while scanning for the next token", None,
yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
  in "<unicode string>", line 11, column 3:
      	Still by two   # content nor
      ^

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 =WSPC|..
   1    2    2    2 +COMM|
   1    2    2    2 =SYNX|#
   1    3    3    3 =META|.Leading.comment.line.spaces.are
   1   35   35   35 -COMM|
   1   35   35   35 =EOL |\x0a
   2    0   36   36 =WSPC|...
   2    3   39   39 +COMM|
   2    3   39   39 =SYNX|#
   2    4   40   40 =META|.neither.content.nor.indentation.
   2   37   73   73 -COMM|
   2   37   73   73 =EOL |\x0a
   3    0   74   74 =WSPC|....
   3    4   78   78 =EOL |\x0a
   4    0   79   79 +DOC |
   4    0   79   79 +NODE|
   4    0   79   79 +MAP |
   4    0   79   79 +PAIR|
   4    0   79   79 +NODE|
   4    0   79   79 +VAL |
   4    0   79   79 =TEXT|Not.indented
   4   12   91   91 -VAL |
   4   12   91   91 -NODE|
   4   12   91   91 =SYNX|:
   4   13   92   92 +NODE|
   4   13   92   92 =EOL |\x0a
   5    0   93   93 +MAP |
   5    0   93   93 =DENT|.
   5    1   94   94 +PAIR|
   5    1   94   94 +NODE|
   5    1   94   94 +VAL |
   5    1   94   94 =TEXT|By.one.space
   5   13  106  106 -VAL |
   5   13  106  106 -NODE|
   5   13  106  106 =SYNX|:
   5   14  107  107 +NODE|
   5   14  107  107 =WSPC|.
   5   15  108  108 +VAL |
   5   15  108  108 =SYNX||
   5   16  109  109 =EOL |\x0a
   6    0  110  110 =DENT|....
   6    4  114  114 =TEXT|By.four
   6   11  121  121 =NEWL|\x0a
   7    0  122  122 =DENT|....
   7    4  126  126 =TEXT|..spaces
   7   12  134  134 =NEWL|\x0a
   8    0  135  135 -VAL |
   8    0  135  135 -NODE|
   8    0  135  135 -PAIR|
   8    0  135  135 =DENT|.
   8    1  136  136 +PAIR|
   8    1  136  136 +NODE|
   8    1  136  136 +VAL |
   8    1  136  136 =TEXT|Flow.style
   8   11  146  146 -VAL |
   8   11  146  146 -NODE|
   8   11  146  146 =SYNX|:
   8   12  147  147 =WSPC|.
   8   13  148  148 +NODE|
   8   13  148  148 +SEQ |
   8   13  148  148 =SYNX|[
   8   14  149  149 =WSPC|....
   8   18  153  153 +COMM|
   8   18  153  153 =SYNX|#
   8   19  154  154 =META|.Leading.spaces
   8   34  169  169 -COMM|
   8   34  169  169 =EOL |\x0a
   9    0  170  170 =DENT|..
   9    2  172  172 =WSPC|.
   9    3  173  173 +NODE|
   9    3  173  173 +VAL |
   9    3  173  173 =TEXT|By.two
   9    9  179  179 -VAL |
   9    9  179  179 -NODE|
   9    9  179  179 =SYNX|,
   9   10  180  180 =WSPC|........
   9   18  188  188 +COMM|
   9   18  188  188 =SYNX|#
   9   19  189  189 =META|.in.flow.style
   9   33  203  203 -COMM|
   9   33  203  203 =EOL |\x0a
  10    0  204  204 =DENT|..
  10    2  206  206 +NODE|
  10    2  206  206 +VAL |
  10    2  206  206 =TEXT|Also.by.two
  10   13  217  217 -VAL |
  10   13  217  217 -NODE|
  10   13  217  217 =SYNX|,
  10   14  218  218 =WSPC|....
  10   18  222  222 +COMM|
  10   18  222  222 =SYNX|#
  10   19  223  223 =META|.are.neither
  10   31  235  235 -COMM|
  10   31  235  235 =EOL |\x0a
  11    0  236  236 =DENT|..
  11    2  238  238 =WSPC|\x09
  11    3  239  239 +NODE|
  11    3  239  239 +VAL |
  11    3  239  239 =TEXT|Still.by.two
  11   15  251  251 -VAL |
  11   15  251  251 -NODE|
  11   15  251  251 =WSPC|...
  11   18  254  254 +COMM|
  11   18  254  254 =SYNX|#
  11   19  255  255 =META|.content.nor
  11   31  267  267 -COMM|
  11   31  267  267 =EOL |\x0a
  12    0  268  268 =DENT|..
  12    2  270  270 =WSPC|..
  12    4  272  272 =SYNX|]
  12    5  273  273 -SEQ |
  12    5  273  273 -NODE|
  12    5  273  273 =WSPC|.............
  12   18  286  286 +COMM|
  12   18  286  286 =SYNX|#
  12   19  287  287 =META|.indentation.
  12   32  300  300 -COMM|
  12   32  300  300 =EOL |\x0a
  13    0  301  301 -PAIR|
  13    0  301  301 -MAP |
  13    0  301  301 -NODE|
  13    0  301  301 -PAIR|
  13    0  301  301 -MAP |
  13    0  301  301 -NODE|
  13    0  301  301 -DOC |

perl-pp-perl

 na
{
  'Not indented' => {
                      'By one space' => 'By four
  spaces
',
                      'Flow style' => [
                                        'By two',
                                        'Also by two',
                                        'Still by two'
                                      ]
                    }
}

perl-pplibyaml-perl

 na
{
  'Not indented' => {
                      'By one space' => 'By four
  spaces
',
                      'Flow style' => [
                                        'By two',
                                        'Also by two',
                                        'Still by two'
                                      ]
                    }
}

perl-syck-perl

 na
{
  'Not indented' => {
                      'By one space' => 'By four
  spaces
',
                      'Flow style' => [
                                        'By two',
                                        'Also by two',
                                        'Still by two'
                                      ]
                    }
}

perl-xs-perl

 na
{
  'Not indented' => {
                      'By one space' => 'By four
  spaces
',
                      'Flow style' => [
                                        'By two',
                                        'Also by two',
                                        'Still by two'
                                      ]
                    }
}

py-ruamel-py

 na
{'Not indented': {'By one space': 'By four\n  spaces\n',
                  'Flow style': ['By two', 'Also by two', 'Still by two']}}

perl-tiny-json

 ni
YAML::Tiny found bad indenting in line '   By two,        # in flow style' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 ni
YAML::Tiny found bad indenting in line '   By two,        # in flow style' at /yaml/bin/perl-tiny-perl line 15.