# YAML Test Matrix

--- &test-JR7V
  Title: Question marks in scalars
  Tags: [ flow, scalar ]

YAML

- a?string
- another ? string
- key: value?
- [a?string]
- [another ? string]
- {key: value? }
- {key: value?}
- {key?: value }

Expected Events

+STR
+DOC
+SEQ
=VAL :a?string
=VAL :another ? string
+MAP
=VAL :key
=VAL :value?
-MAP
+SEQ []
=VAL :a?string
-SEQ
+SEQ []
=VAL :another ? string
-SEQ
+MAP {}
=VAL :key
=VAL :value?
-MAP
+MAP {}
=VAL :key
=VAL :value?
-MAP
+MAP {}
=VAL :key?
=VAL :value
-MAP
-SEQ
-DOC
-STR

Expected JSON

[
"a?string",
"another ? string",
{
"key": "value?"
},
[
"a?string"
],
[
"another ? string"
],
{
"key": "value?"
},
{
"key": "value?"
},
{
"key?": "value"
}
]

c-libfyaml-event

 ok

c-libyaml-event

 ok

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

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-yaml-json

 json_ok

py-ruamel-json

 json_ok

ruby-psych-json

 json_ok

perl-tiny-json

 json_diff
[
  "a?string",
  "another ? string",
  {
    "key": "value?"
  },
  "[a?string]",
  "[another ? string]",
  {
    "{key": "value? }"
  },
  {
    "{key": "value?}"
  },
  {
    "{key?": "value }"
  }
]

cpp-yamlcpp-event

 error
+STR
+DOC
+SEQ
=VAL :a?string
=VAL :another ? string
+MAP
=VAL :key
=VAL :value?
-MAP
Exception:
yaml-cpp: error at line 4, column 5: unknown token

dotnet-yamldotnet-event

 error
+STR
+DOC
+SEQ
=VAL :a?string
=VAL :another ? string
+MAP
=VAL :key
=VAL :value?
-MAP
+SEQ
=VAL :a
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 4, Col: 5, Idx: 48) - (Line: 4, Col: 6, Idx: 49): While parsing a flow sequence, did not find expected ',' or ']'.
   at YamlDotNet.Core.Parser.ParseFlowSequenceEntry(Boolean isFirst)
   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)

dotnet-yamldotnet-json

 error
Unhandled exception. YamlDotNet.Core.SemanticErrorException: (Line: 4, Col: 5, Idx: 48) - (Line: 4, Col: 6, Idx: 49): While parsing a flow sequence, did not find expected ',' or ']'.
   at YamlDotNet.Core.Parser.ParseFlowSequenceEntry(Boolean isFirst)
   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.CollectionNodeDeserializer.DeserializeHelper(Type tItem, IParser parser, Func`3 nestedObjectDeserializer, IList result, Boolean canUpdate)
   at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.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.CollectionNodeDeserializer.DeserializeHelper(Type tItem, IParser parser, Func`3 nestedObjectDeserializer, IList result, Boolean canUpdate)
   at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.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)

go-yaml-json

 error
yaml: line 3: did not find expected ',' or ']'

perl-xs-json

 error
YAML::XS::Load Error: The problem:

    did not find expected ',' or ']'

was found at document: 1, line: 4, column: 5
while parsing a flow sequence at line: 4, column: 3

perl-xs-perl

 error
YAML::XS::Load Error: The problem:

    did not find expected ',' or ']'

was found at document: 1, line: 4, column: 5
while parsing a flow sequence at line: 4, column: 3

py-pyyaml-event

 error
+STR
+DOC
+SEQ
=VAL :a?string
=VAL :another ? string
+MAP
=VAL :key
=VAL :value?
-MAP
+SEQ []
=VAL :a
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 483, in parse_flow_sequence_entry
    raise ParserError("while parsing a flow sequence", self.marks[-1],
yaml.parser.ParserError: while parsing a flow sequence
  in "<unicode string>", line 4, column 3:
    - [a?string]
      ^
expected ',' or ']', but got '?'
  in "<unicode string>", line 4, column 5:
    - [a?string]
        ^

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 82, in compose_node
    node = self.compose_sequence_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 483, in parse_flow_sequence_entry
    raise ParserError("while parsing a flow sequence", self.marks[-1],
yaml.parser.ParserError: while parsing a flow sequence
  in "<unicode string>", line 4, column 3:
    - [a?string]
      ^
expected ',' or ']', but got '?'
  in "<unicode string>", line 4, column 5:
    - [a?string]
        ^

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 82, in compose_node
    node = self.compose_sequence_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 483, in parse_flow_sequence_entry
    raise ParserError("while parsing a flow sequence", self.marks[-1],
yaml.parser.ParserError: while parsing a flow sequence
  in "<unicode string>", line 4, column 3:
    - [a?string]
      ^
expected ',' or ']', but got '?'
  in "<unicode string>", line 4, column 5:
    - [a?string]
        ^

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 +NODE|
   1    0    0    0 +SEQ |
   1    0    0    0 =SYNX|-
   1    1    1    1 =WSPC|.
   1    2    2    2 +NODE|
   1    2    2    2 +VAL |
   1    2    2    2 =TEXT|a?string
   1   10   10   10 -VAL |
   1   10   10   10 -NODE|
   1   10   10   10 =EOL |\x0a
   2    0   11   11 =SYNX|-
   2    1   12   12 =WSPC|.
   2    2   13   13 +NODE|
   2    2   13   13 +VAL |
   2    2   13   13 =TEXT|another.?.string
   2   18   29   29 -VAL |
   2   18   29   29 -NODE|
   2   18   29   29 =EOL |\x0a
   3    0   30   30 =SYNX|-
   3    1   31   31 =DENT|.
   3    2   32   32 +NODE|
   3    2   32   32 +MAP |
   3    2   32   32 +PAIR|
   3    2   32   32 +NODE|
   3    2   32   32 +VAL |
   3    2   32   32 =TEXT|key
   3    5   35   35 -VAL |
   3    5   35   35 -NODE|
   3    5   35   35 =SYNX|:
   3    6   36   36 =WSPC|.
   3    7   37   37 +NODE|
   3    7   37   37 +VAL |
   3    7   37   37 =TEXT|value?
   3   13   43   43 -VAL |
   3   13   43   43 -NODE|
   3   13   43   43 =EOL |\x0a
   4    0   44   44 -PAIR|
   4    0   44   44 -MAP |
   4    0   44   44 -NODE|
   4    0   44   44 =SYNX|-
   4    1   45   45 =WSPC|.
   4    2   46   46 +NODE|
   4    2   46   46 +SEQ |
   4    2   46   46 =SYNX|[
   4    3   47   47 +NODE|
   4    3   47   47 +VAL |
   4    3   47   47 =TEXT|a?string
   4   11   55   55 -VAL |
   4   11   55   55 -NODE|
   4   11   55   55 =SYNX|]
   4   12   56   56 -SEQ |
   4   12   56   56 -NODE|
   4   12   56   56 =EOL |\x0a
   5    0   57   57 =SYNX|-
   5    1   58   58 =WSPC|.
   5    2   59   59 +NODE|
   5    2   59   59 +SEQ |
   5    2   59   59 =SYNX|[
   5    3   60   60 +NODE|
   5    3   60   60 +VAL |
   5    3   60   60 =TEXT|another.?.string
   5   19   76   76 -VAL |
   5   19   76   76 -NODE|
   5   19   76   76 =SYNX|]
   5   20   77   77 -SEQ |
   5   20   77   77 -NODE|
   5   20   77   77 =EOL |\x0a
   6    0   78   78 =SYNX|-
   6    1   79   79 =WSPC|.
   6    2   80   80 +NODE|
   6    2   80   80 +MAP |
   6    2   80   80 =SYNX|{
   6    3   81   81 +PAIR|
   6    3   81   81 +NODE|
   6    3   81   81 +VAL |
   6    3   81   81 =TEXT|key
   6    6   84   84 -VAL |
   6    6   84   84 -NODE|
   6    6   84   84 =SYNX|:
   6    7   85   85 =WSPC|.
   6    8   86   86 +NODE|
   6    8   86   86 +VAL |
   6    8   86   86 =TEXT|value?
   6   14   92   92 -VAL |
   6   14   92   92 -NODE|
   6   14   92   92 -PAIR|
   6   14   92   92 =WSPC|.
   6   15   93   93 =SYNX|}
   6   16   94   94 -MAP |
   6   16   94   94 -NODE|
   6   16   94   94 =EOL |\x0a
   7    0   95   95 =SYNX|-
   7    1   96   96 =WSPC|.
   7    2   97   97 +NODE|
   7    2   97   97 +MAP |
   7    2   97   97 =SYNX|{
   7    3   98   98 +PAIR|
   7    3   98   98 +NODE|
   7    3   98   98 +VAL |
   7    3   98   98 =TEXT|key
   7    6  101  101 -VAL |
   7    6  101  101 -NODE|
   7    6  101  101 =SYNX|:
   7    7  102  102 =WSPC|.
   7    8  103  103 +NODE|
   7    8  103  103 +VAL |
   7    8  103  103 =TEXT|value?
   7   14  109  109 -VAL |
   7   14  109  109 -NODE|
   7   14  109  109 -PAIR|
   7   14  109  109 =SYNX|}
   7   15  110  110 -MAP |
   7   15  110  110 -NODE|
   7   15  110  110 =EOL |\x0a
   8    0  111  111 =SYNX|-
   8    1  112  112 =WSPC|.
   8    2  113  113 +NODE|
   8    2  113  113 +MAP |
   8    2  113  113 =SYNX|{
   8    3  114  114 +PAIR|
   8    3  114  114 +NODE|
   8    3  114  114 +VAL |
   8    3  114  114 =TEXT|key?
   8    7  118  118 -VAL |
   8    7  118  118 -NODE|
   8    7  118  118 =SYNX|:
   8    8  119  119 =WSPC|.
   8    9  120  120 +NODE|
   8    9  120  120 +VAL |
   8    9  120  120 =TEXT|value
   8   14  125  125 -VAL |
   8   14  125  125 -NODE|
   8   14  125  125 -PAIR|
   8   14  125  125 =WSPC|.
   8   15  126  126 =SYNX|}
   8   16  127  127 -MAP |
   8   16  127  127 -NODE|
   8   16  127  127 =EOL |\x0a
   9    0  128  128 -SEQ |
   9    0  128  128 -NODE|
   9    0  128  128 -DOC |

perl-pp-perl

 na
[
  'a?string',
  'another ? string',
  {
    'key' => 'value?'
  },
  [
    'a?string'
  ],
  [
    'another ? string'
  ],
  {
    'key' => 'value?'
  },
  {
    'key' => 'value?'
  },
  {
    'key?' => 'value'
  }
]

perl-pplibyaml-perl

 na
[
  'a?string',
  'another ? string',
  {
    'key' => 'value?'
  },
  [
    'a?string'
  ],
  [
    'another ? string'
  ],
  {
    'key' => 'value?'
  },
  {
    'key' => 'value?'
  },
  {
    'key?' => 'value'
  }
]

perl-syck-perl

 na
[
  'a?string',
  'another ? string',
  {
    'key' => 'value?'
  },
  [
    'a?string'
  ],
  [
    'another ? string'
  ],
  {
    'key' => 'value?'
  },
  {
    'key' => 'value?'
  },
  {
    'key?' => 'value'
  }
]

perl-tiny-perl

 na
[
  'a?string',
  'another ? string',
  {
    'key' => 'value?'
  },
  '[a?string]',
  '[another ? string]',
  {
    '{key' => 'value? }'
  },
  {
    '{key' => 'value?}'
  },
  {
    '{key?' => 'value }'
  }
]

perl-yaml-perl

 na
[
  'a?string',
  'another ? string',
  {
    'key' => 'value?'
  },
  [
    'a?string'
  ],
  [
    'another ? string'
  ],
  {
    'key' => 'value?'
  },
  {
    'key' => 'value?'
  },
  {
    'key?' => 'value'
  }
]

py-ruamel-py

 na
['a?string',
 'another ? string',
 {'key': 'value?'},
 ['a?string'],
 ['another ? string'],
 {'key': 'value?'},
 {'key': 'value?'},
 {'key?': 'value'}]