# YAML Test Matrix

--- &test-PW8X
  Title: Anchors on Empty Scalars
  Tags: [ anchor, empty, missing ]

YAML

- &a
- a
-
  &a : a
  b: &b
  &c : &a
-
  ? &d
  ? &e
  : &a

Expected Events

+STR
+DOC
+SEQ
=VAL &a :
=VAL :a
+MAP
=VAL &a :
=VAL :a
=VAL :b
=VAL &b :
=VAL &c :
=VAL &a :
-MAP
+MAP
=VAL &d :
=VAL :
=VAL &e :
=VAL &a :
-MAP
-SEQ
-DOC
-STR

Expected JSON

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

cpp-event

 ok

hs-yaml-event

 ok

java-event

 ok

libyaml-event

 ok

nimyaml-event

 ok

perl5-pp-event

 ok

pyyaml-event

 ok

ruamel-event

 ok

hs-yaml-json

 json_ok

perl5-pp-json

 json_ok

perl5-xs-json

 json_ok

ruby-json

 json_ok

java-json

 json_diff
[
  null,
  "a",
  {},
  {}
]

luajit-json

 json_diff
[
  "",
  "a",
  {
    "": "",
    "b": ""
  },
  {
    "": ""
  }
]

ruamel-json

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

js-event

 error
+STR
+DOC
+SEQ
=VAL &a :
=VAL :a
undefined

js-json

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

YAMLSemanticError: Map keys must be unique; "null" is repeated
    at Object.parseMap [as resolve] (/node_modules/yaml/dist/schema/parseMap.js:68:27)
    at Schema.resolveNode (/node_modules/yaml/dist/schema/index.js:123:27)
    at Schema.resolveNodeWithFallback (/node_modules/yaml/dist/schema/index.js:145:22)
    at Document.resolveNode (/node_modules/yaml/dist/Document.js:380:22)
    at resolveBlockSeqItems (/node_modules/yaml/dist/schema/parseSeq.js:55:24)
    at Object.parseSeq [as resolve] (/node_modules/yaml/dist/schema/parseSeq.js:27:83)
    at Schema.resolveNode (/node_modules/yaml/dist/schema/index.js:123:27)
    at Schema.resolveNodeWithFallback (/node_modules/yaml/dist/schema/index.js:145:22)
    at Document.resolveNode (/node_modules/yaml/dist/Document.js:380:22)
    at contents.forEach.node (/node_modules/yaml/dist/Document.js:122:32)

js-yaml-json

 error
YAMLException: bad indentation of a sequence entry at line 4, column 6:
      &a : a
         ^
    at generateError (/node_modules/js-yaml/lib/js-yaml/loader.js:165:10)
    at throwError (/node_modules/js-yaml/lib/js-yaml/loader.js:171:9)
    at readBlockSequence (/node_modules/js-yaml/lib/js-yaml/loader.js:935:7)
    at composeNode (/node_modules/js-yaml/lib/js-yaml/loader.js:1331:12)
    at readDocument (/node_modules/js-yaml/lib/js-yaml/loader.js:1492:3)
    at loadDocuments (/node_modules/js-yaml/lib/js-yaml/loader.js:1548:5)
    at Object.loadAll (/node_modules/js-yaml/lib/js-yaml/loader.js:1556:19)
    at Object.<anonymous> (/bin/js-yaml-json:6:6)
    at Object.<anonymous> (/bin/js-yaml-json:3:1)
    at Module._compile (module.js:652:30)
    at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:173:23)
    at compileScript (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
    at compilePath (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
    at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
    at Object.<anonymous> (/usr/lib/node_modules/coffee-script/bin/coffee:15:45)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

perl5-pegex-event

 error
Maximum parsing rules reached (1000)

perl5-pm-json

 error
Use of uninitialized value $key in string at /lib/perl5/YAML/Loader.pm line 341, <> line 1.
YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 9
   Document: 1
 at /lib/perl5/YAML/Loader.pm line 360.

perl5-pm-pl

 error
Use of uninitialized value $key in string at /lib/perl5/YAML/Loader.pm line 341, <> line 1.
YAML Error: Invalid element in map
   Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
   Line: 9
   Document: 1
 at /lib/perl5/YAML/Loader.pm line 360.

perl5-syck-json

 error
Syck parser (line 4, column 6): syntax error at /lib/perl5/x86_64-linux-gnu-thread-multi/YAML/Syck.pm line 75, <> line 1.

perl5-syck-pl

 error
Syck parser (line 4, column 6): syntax error at /lib/perl5/x86_64-linux-gnu-thread-multi/YAML/Syck.pm line 75, <> line 1.

perl5-tiny-json

 error
YAML::Tiny does not support a feature in line '&a' at /bin/perl5-tiny-json line 12.

perl5-tiny-pl

 error
YAML::Tiny does not support a feature in line '&a' at /bin/perl5-tiny-pl line 15.

pyyaml-json

 error
Traceback (most recent call last):
  File "/bin/pyyaml-json", line 19, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/lib/python2.7/site-packages/yaml/__init__.py", line 90, in load_all
    yield loader.get_data()
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 33, in get_data
    return self.construct_document(self.get_node())
  File "/lib/python2.7/site-packages/yaml/composer.py", line 27, in get_node
    return self.compose_document()
  File "/lib/python2.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
  File "/lib/python2.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 129, in compose_mapping_node
    item_key = self.compose_node(node, None)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 77, in compose_node
    "second occurrence", event.start_mark)
yaml.composer.ComposerError: found duplicate anchor 'a'; first occurrence
  in "<string>", line 1, column 3:
    - &a
      ^
second occurrence
  in "<string>", line 4, column 3:
      &a : a
      ^

pyyaml-py

 error
Traceback (most recent call last):
  File "/bin/pyyaml-py", line 36, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/lib/python2.7/site-packages/yaml/__init__.py", line 90, in load_all
    yield loader.get_data()
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 33, in get_data
    return self.construct_document(self.get_node())
  File "/lib/python2.7/site-packages/yaml/composer.py", line 27, in get_node
    return self.compose_document()
  File "/lib/python2.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
  File "/lib/python2.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 129, in compose_mapping_node
    item_key = self.compose_node(node, None)
  File "/lib/python2.7/site-packages/yaml/composer.py", line 77, in compose_node
    "second occurrence", event.start_mark)
yaml.composer.ComposerError: found duplicate anchor 'a'; first occurrence
  in "<string>", line 1, column 3:
    - &a
      ^
second occurrence
  in "<string>", line 4, column 3:
      &a : a
      ^

perl5-pp-pl

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

perl5-xs-pl

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

ruamel-py

 na
[None, 'a', {None: None, 'b': None}, {None: None}]
/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py:131: ReusedAnchorWarning: 
found duplicate anchor u'a'
first occurrence   in "<byte string>", line 1, column 3:
    - &a
      ^ (line: 1)
second occurrence   in "<byte string>", line 4, column 3:
      &a : a
      ^ (line: 4)
  warnings.warn(ws, ReusedAnchorWarning)
/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py:131: ReusedAnchorWarning: 
found duplicate anchor u'a'
first occurrence   in "<byte string>", line 4, column 3:
      &a : a
      ^ (line: 4)
second occurrence   in "<byte string>", line 6, column 8:
      &c : &a
           ^ (line: 6)
  warnings.warn(ws, ReusedAnchorWarning)
/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py:131: ReusedAnchorWarning: 
found duplicate anchor u'a'
first occurrence   in "<byte string>", line 6, column 8:
      &c : &a
           ^ (line: 6)
second occurrence   in "<byte string>", line 10, column 5:
      : &a
        ^ (line: 10)
  warnings.warn(ws, ReusedAnchorWarning)
/usr/local/lib/python2.7/dist-packages/ruamel/yaml/constructor.py:276: DuplicateKeyFutureWarning: while constructing a mapping
  in "<byte string>", line 4, column 3:
      &a : a
      ^ (line: 4)
found duplicate key "None" with value "None" (original value: "a")
  in "<byte string>", line 6, column 3:
      &c : &a
      ^ (line: 6)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

Duplicate keys will become an error in future releases, and are errors
by default when using the new API.

  warnings.warn(DuplicateKeyFutureWarning(*args))
/usr/local/lib/python2.7/dist-packages/ruamel/yaml/constructor.py:276: DuplicateKeyFutureWarning: while constructing a mapping
  in "<byte string>", line 8, column 3:
      ? &d
      ^ (line: 8)
found duplicate key "None" with value "None" (original value: "None")
  in "<byte string>", line 9, column 5:
      ? &e
        ^ (line: 9)

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

Duplicate keys will become an error in future releases, and are errors
by default when using the new API.

  warnings.warn(DuplicateKeyFutureWarning(*args))