# YAML Test Matrix

--- &test-S98Z
  Title: Block scalar with more spaces than first content line
  Tags: [ comment, error, folded, scalar, whitespace ]

YAML

empty block scalar: >
 
  
   
 # comment

Expected Events

+STR
+DOC
+MAP
=VAL :empty block scalar

Expected JSON



c-libyaml-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL >
-MAP
-DOC
-STR

cpp-rapidyaml-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL '
-MAP
-DOC
-STR

cpp-yamlcpp-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL :
-MAP
-DOC
-STR

go-yaml-json

 invalid_incorrect
{"empty block scalar":""}

hs-reference-yeast

 invalid_incorrect
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|empty.block.scalar
   1   18   18   18 -VAL |
   1   18   18   18 -NODE|
   1   18   18   18 =SYNX|:
   1   19   19   19 +NODE|
   1   19   19   19 =WSPC|.
   1   20   20   20 +VAL |
   1   20   20   20 =SYNX|>
   1   21   21   21 =EOL |\x0a
   2    0   22   22 =DENT|.
   2    1   23   23 =NEWL|\x0a
   3    0   24   24 =DENT|.
   3    1   25   25 =TEXT|.
   3    2   26   26 =NEWL|\x0a
   4    0   27   27 =DENT|.
   4    1   28   28 =TEXT|..
   4    3   30   30 =NEWL|\x0a
   5    0   31   31 =DENT|.
   5    1   32   32 =TEXT|#.comment
   5   10   41   41 =NEWL|\x0a
   6    0   42   42 -VAL |
   6    0   42   42 -NODE|
   6    0   42   42 -PAIR|
   6    0   42   42 -MAP |
   6    0   42   42 -NODE|
   6    0   42   42 -DOC |

js-jsyaml-json

 invalid_incorrect
{"empty block scalar":""}

lua-lyaml-json

 invalid_incorrect
{"empty block scalar":""}

perl-pp-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL >
-MAP
-DOC
-STR

perl-pp-json

 invalid_incorrect
{
   "empty block scalar" : ""
}

perl-pp-perl

 invalid_incorrect
{
  'empty block scalar' => ''
}

perl-pplibyaml-json

 invalid_incorrect
{
   "empty block scalar" : ""
}

perl-pplibyaml-perl

 invalid_incorrect
{
  'empty block scalar' => ''
}

perl-syck-json

 invalid_incorrect
{
   "empty block scalar" : "\n\n\n# comment\n"
}

perl-syck-perl

 invalid_incorrect
{
  'empty block scalar' => '


# comment
'
}

perl-xs-json

 invalid_incorrect
{
   "empty block scalar" : ""
}

perl-xs-perl

 invalid_incorrect
{
  'empty block scalar' => ''
}

perl-yaml-json

 invalid_incorrect
{
   "empty block scalar" : "\n \n  \n# comment\n"
}

perl-yaml-perl

 invalid_incorrect
{
  'empty block scalar' => '
 
  
# comment
'
}

py-pyyaml-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL >
-MAP
-DOC
-STR

py-pyyaml-json

 invalid_incorrect
{
  "empty block scalar": ""
}

py-pyyaml-py

 invalid_incorrect
{'empty block scalar': ''}

ruby-psych-json

 invalid_incorrect
{"empty block scalar":""}

rust-yamlrust-event

 invalid_incorrect
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL >
-MAP
-DOC
-STR

c-libfyaml-event

 invalid_correct
stdin:2:1: error: empty block scalar with wrongly indented comment line after spaces only
 
^
  
~~
   
~~~
 # comment
~
+STR
+DOC
+MAP
=VAL :empty block scalar

c-libfyaml-json

 invalid_correct
stdin:2:1: error: empty block scalar with wrongly indented comment line after spaces only
 
^
  
~~
   
~~~
 # comment
~

dotnet-yamldotnet-event

 invalid_correct
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 5, Col: 1, Idx: 31) - (Line: 5, Col: 2, Idx: 32): While scanning a literal block scalar, found more spaces in lines above first content line.
   at YamlDotNet.Core.Scanner.ScanBlockScalarBreaks(Int32 currentIndent, StringBuilder breaks, Boolean isLiteral, Mark& end, Nullable`1& isFirstLine)
   at YamlDotNet.Core.Scanner.ScanBlockScalar(Boolean isLiteral)
   at YamlDotNet.Core.Scanner.FetchBlockScalar(Boolean isLiteral)
   at YamlDotNet.Core.Scanner.FetchNextToken()
   at YamlDotNet.Core.Scanner.FetchMoreTokens()
   at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming()
   at YamlDotNet.Core.Parser.GetCurrentToken()
   at YamlDotNet.Core.Parser.ParseBlockMappingValue()
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.RepresentationModel.LibYamlEventStream.WriteTo(TextWriter textWriter)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)
+STR
+DOC
+MAP
=VAL :empty block scalar

dotnet-yamldotnet-json

 invalid_correct
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 5, Col: 1, Idx: 31) - (Line: 5, Col: 2, Idx: 32): While scanning a literal block scalar, found more spaces in lines above first content line.
   at YamlDotNet.Core.Scanner.ScanBlockScalarBreaks(Int32 currentIndent, StringBuilder breaks, Boolean isLiteral, Mark& end, Nullable`1& isFirstLine)
   at YamlDotNet.Core.Scanner.ScanBlockScalar(Boolean isLiteral)
   at YamlDotNet.Core.Scanner.FetchBlockScalar(Boolean isLiteral)
   at YamlDotNet.Core.Scanner.FetchNextToken()
   at YamlDotNet.Core.Scanner.FetchMoreTokens()
   at YamlDotNet.Core.Scanner.MoveNextWithoutConsuming()
   at YamlDotNet.Core.Parser.GetCurrentToken()
   at YamlDotNet.Core.Parser.ParseBlockMappingValue()
   at YamlDotNet.Core.Parser.StateMachine()
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.TryConsume[T](IParser parser, T& event)
   at YamlDotNet.Serialization.NodeDeserializers.ScalarNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.DeserializeHelper(Type tKey, Type tValue, IParser parser, Func`3 nestedObjectDeserializer, IDictionary result)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)

hs-hsyaml-event

 invalid_correct
Parsing error near byte offset Pos {posByteOffset = 42, posCharOffset = 42, posLine = 6, posColumn = 0} (leading empty lines contain more spaces than the first non-empty line in scalar: "\n \n  \n# comment\n")
+STR
+DOC
+MAP
=VAL :empty block scalar

hs-hsyaml-json

 invalid_correct
hsyaml-parser: user error (leading empty lines contain more spaces than the first non-empty line in scalar: "\n \n  \n# comment\n")

js-yaml-event

 invalid_correct
Block scalars with more-indented leading empty lines must use an explicit indentation indicator at line 5, column 2:

   
 # comment
 ^
+STR
+DOC
+MAP
=VAL :empty block scalar
=VAL >\n \n  \n# comment\n
-MAP
-DOC
-STR

js-yaml-json

 invalid_correct
/yaml/bin/js-yaml-json:9
    if (doc.errors.length !== 0) throw doc.errors[0]
                                 ^

YAMLParseError: Block scalars with more-indented leading empty lines must use an explicit indentation indicator at line 5, column 2:

   
 # comment
 ^

    at Composer.onError (/node/node_modules/yaml/dist/compose/composer.js:69:34)
    at Object.resolveBlockScalar (/node/node_modules/yaml/dist/compose/resolve-block-scalar.js:44:17)
    at Object.composeScalar (/node/node_modules/yaml/dist/compose/compose-scalar.js:10:30)
    at composeNode (/node/node_modules/yaml/dist/compose/compose-node.js:24:34)
    at Object.resolveBlockMap (/node/node_modules/yaml/dist/compose/resolve-block-map.js:83:19)
    at resolveCollection (/node/node_modules/yaml/dist/compose/compose-collection.js:13:27)
    at Object.composeCollection (/node/node_modules/yaml/dist/compose/compose-collection.js:47:16)
    at Object.composeNode (/node/node_modules/yaml/dist/compose/compose-node.js:31:38)
    at Object.composeDoc (/node/node_modules/yaml/dist/compose/compose-doc.js:34:23)
    at Composer.next (/node/node_modules/yaml/dist/compose/composer.js:149:40) {
  code: 'MISSING_CHAR',
  pos: [ 32, 33 ],
  linePos: [ { line: 5, col: 2 }, { line: 5, col: 3 } ]
}

Node.js v20.13.1

nim-nimyaml-event

 invalid_correct
/tmp/NimYAML-0.16.0/yaml/stream.nim(134) nimyaml_event
/tmp/NimYAML-0.16.0/yaml/stream.nim(106) next
Error: unhandled exception: Leading all-spaces line contains too many spaces [YamlStreamError]
+STR
+DOC
+MAP
=VAL :empty block scalar

perl-refparser-event

 invalid_correct
Spaces found after indent in auto-detect (5LLU) at /perl5/lib/perl5/YAML/Parser.pm line 4588, <> line 1.

perl-tiny-json

 invalid_correct
YAML::Tiny failed to find multi-line scalar content at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 invalid_correct
YAML::Tiny failed to find multi-line scalar content at /yaml/bin/perl-tiny-perl line 15.

py-ruamel-event

 invalid_correct
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-event", line 9, in <module>
    for event in yaml.parse(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 371, in parse
    while parser.check_event():
          ^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 631, in parse_block_mapping_value
    if self.scanner.check_token(ValueToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 170, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 298, in fetch_more_tokens
    return self.fetch_folded()
           ^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 683, in fetch_folded
    self.fetch_block_scalar(style='>')
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 691, in fetch_block_scalar
    self.tokens.append(self.scan_block_scalar(style))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 1128, in scan_block_scalar
    breaks, max_indent, end_mark = self.scan_block_scalar_indentation()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 1317, in scan_block_scalar_indentation
    raise ScannerError(
ruamel.yaml.scanner.ScannerError: more indented follow up line than first in a block scalar
  in "<unicode string>", line 5, column 2:
     # comment
     ^ (line: 5)
+STR
+DOC
+MAP
=VAL :empty block scalar

py-ruamel-json

 invalid_correct
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 21, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 476, in load_all
    yield constructor.get_data()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 110, in get_data
    return self.construct_document(self.composer.get_node())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 63, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 94, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 130, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 211, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 106, in compose_node
    if self.parser.check_event(AliasEvent):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 631, in parse_block_mapping_value
    if self.scanner.check_token(ValueToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 170, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 298, in fetch_more_tokens
    return self.fetch_folded()
           ^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 683, in fetch_folded
    self.fetch_block_scalar(style='>')
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 691, in fetch_block_scalar
    self.tokens.append(self.scan_block_scalar(style))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 1128, in scan_block_scalar
    breaks, max_indent, end_mark = self.scan_block_scalar_indentation()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 1317, in scan_block_scalar_indentation
    raise ScannerError(
ruamel.yaml.scanner.ScannerError: more indented follow up line than first in a block scalar
  in "<unicode string>", line 5, column 2:
     # comment
     ^ (line: 5)

py-ruamel-py

 invalid_correct
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-py", line 38, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 476, in load_all
    yield constructor.get_data()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 110, in get_data
    return self.construct_document(self.composer.get_node())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 63, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 94, in compose_document
    node = self.compose_node(None, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 130, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 211, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 106, in compose_node
    if self.parser.check_event(AliasEvent):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 631, in parse_block_mapping_value
    if self.scanner.check_token(ValueToken):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 170, in check_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 298, in fetch_more_tokens
    return self.fetch_folded()
           ^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 683, in fetch_folded
    self.fetch_block_scalar(style='>')
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 691, in fetch_block_scalar
    self.tokens.append(self.scan_block_scalar(style))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 1128, in scan_block_scalar
    breaks, max_indent, end_mark = self.scan_block_scalar_indentation()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/scanner.py", line 1317, in scan_block_scalar_indentation
    raise ScannerError(
ruamel.yaml.scanner.ScannerError: more indented follow up line than first in a block scalar
  in "<unicode string>", line 5, column 2:
     # comment
     ^ (line: 5)