# YAML Test Matrix

--- &test-FH7J
  Title: Tags on Empty Scalars
  Tags: [ scalar, tag ]

YAML

- !!str
-
  !!null : a
  b: !!str
- !!str : !!null

Expected Events

+STR
+DOC
+SEQ
=VAL <tag:yaml.org,2002:str> :
+MAP
=VAL <tag:yaml.org,2002:null> :
=VAL :a
=VAL :b
=VAL <tag:yaml.org,2002:str> :
-MAP
+MAP
=VAL <tag:yaml.org,2002:str> :
=VAL <tag:yaml.org,2002:null> :
-MAP
-SEQ
-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-snakeyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-pplibyaml-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

perl-syck-perl

 error
Syck parser (line 3, column 10): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

c-libfyaml-json

 na
[
  "",
  {
    "": "a",
    "b": ""
  },
  {
    "": null
  }
]

dotnet-yamldotnet-json

 na
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 3, Col: 3, Idx: 12) - (Line: 3, Col: 11, Idx: 20): Encountered an unresolved tag 'tag:yaml.org,2002:null'
   at YamlDotNet.Serialization.NodeTypeResolvers.PreventUnknownTagsNodeTypeResolver.YamlDotNet.Serialization.INodeTypeResolver.Resolve(NodeEvent nodeEvent, Type& currentType)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.GetTypeFromEvent(NodeEvent nodeEvent, Type currentType)
   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.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)

hs-hsyaml-json

 na
["",{"":"a","b":""},{"":null}]

java-snakeyaml-json

 na
[
  "",
  {
    "null": "a",
    "b": ""
  },
  {}
]

js-jsyaml-json

 na
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: bad indentation of a sequence entry (3:10)

 1 | - !!str
 2 | -
 3 |   !!null : a
--------------^
 4 |   b: !!str
 5 | - !!str : !!null
    at generateError (/node/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/node/node_modules/js-yaml/lib/loader.js:187:9)
    at readBlockSequence (/node/node_modules/js-yaml/lib/loader.js:1015:7)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1440:12)
    at readDocument (/node/node_modules/js-yaml/lib/loader.js:1625:3)
    at loadDocuments (/node/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.loadAll (/node/node_modules/js-yaml/lib/loader.js:1701:19)
    at Object.<anonymous> (/yaml/bin/js-jsyaml-json:7:13)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

js-yaml-json

 na
[
  "",
  {
    "": "a",
    "b": ""
  },
  {
    "": null
  }
]

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 0x557c3b457f97

perl-pp-json

 na
[
   "",
   {
      "" : "a",
      "b" : ""
   },
   {
      "" : null
   }
]

perl-pp-perl

 na
[
  '',
  {
    '' => 'a',
    'b' => ''
  },
  {
    '' => undef
  }
]

perl-pplibyaml-json

 na
[
   "",
   {
      "" : "a",
      "b" : ""
   },
   {
      "" : null
   }
]

perl-pplibyaml-perl

 na
[
  '',
  {
    '' => 'a',
    'b' => ''
  },
  {
    '' => undef
  }
]

perl-syck-json

 na
Syck parser (line 3, column 10): 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 '!!str' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
[
   "",
   {
      "" : "a",
      "b" : ""
   },
   {
      "" : null
   }
]
Use of uninitialized value in subroutine entry at /yaml/bin/perl-xs-json line 14, <> line 1.

perl-xs-perl

 na
[
  '',
  {
    '' => 'a',
    'b' => ''
  },
  {
    '' => undef
  }
]
Use of uninitialized value in subroutine entry at /yaml/bin/perl-xs-perl line 16, <> line 1.

perl-yaml-json

 na
[
   null,
   {
      "" : "a",
      "b" : null
   },
   ": !!null"
]

perl-yaml-perl

 na
[
  undef,
  {
    '' => 'a',
    'b' => undef
  },
  ': !!null'
]

py-pyyaml-json

 na
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-json", line 21, in <module>
    print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.7/json/encoder.py", line 429, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 353, in _iterencode_dict
    items = sorted(dct.items(), key=lambda kv: kv[0])
TypeError: '<' not supported between instances of 'str' and 'NoneType'

py-pyyaml-py

 na
['', {None: 'a', 'b': ''}, {'': None}]

py-ruamel-json

 na
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 21, in <module>
    print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.7/json/encoder.py", line 429, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 353, in _iterencode_dict
    items = sorted(dct.items(), key=lambda kv: kv[0])
TypeError: '<' not supported between instances of 'str' and 'NoneType'

py-ruamel-py

 na
['', {None: 'a', 'b': ''}, {'': None}]

ruby-psych-json

 na
["",{"":"a","b":""},{"":null}]

perl-tiny-perl

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