# YAML Test Matrix

--- &test-6BFJ
  Title: Mapping, key and flow sequence item anchors
  Tags: [ anchor, flow, mapping, sequence ]

YAML

---
&mapping
&key [ &item a, b, c ]: value

Expected Events

+STR
+DOC ---
+MAP &mapping
+SEQ &key
=VAL &item :a
=VAL :b
=VAL :c
-SEQ
=VAL :value
-MAP
-DOC
-STR

Expected JSON



cpp-event

 ok

hs-yaml-event

 ok

java-event

 ok

js-event

 ok

libyaml-event

 ok

nimyaml-event

 ok

pyyaml-event

 ok

ruamel-event

 ok

perl5-pegex-event

 error
Error parsing Pegex document:
  msg:      Parse document failed for some reason
  line:     3
  column:   6
  context:  &key [ &item a, b, c ]: value\n
                 ^
  position: 18 (0 pre-lookahead)
 at /bin/perl5-pegex-event line 23.

perl5-pm-pl

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 2
   Document: 2
 at /lib/perl5/YAML/Loader.pm line 88.

perl5-pp-event

 error
+STR
+DOC ---
+SEQ &key
Line      : 3
Column    : 15
Message   : A node can only have one anchor
Where     : /lib/perl5/YAML/PP/Parser.pm line 775
YAML      : ", b, c ]: value\n"
  at /bin/perl5-pp-event line 19.

perl5-pp-pl

 error
Line      : 3
Column    : 15
Message   : A node can only have one anchor
Where     : /lib/perl5/YAML/PP/Parser.pm line 775
YAML      : ", b, c ]: value\n"
  at /lib/perl5/YAML/PP/Loader.pm line 59.

perl5-syck-pl

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

perl5-tiny-pl

 error
YAML::Tiny failed to classify line '&mapping' at /bin/perl5-tiny-pl line 15.

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/constructor.py", line 48, in construct_document
    for dummy in generator:
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 398, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 208, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 132, in construct_mapping
    "found unacceptable key (%s)" % exc, key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<string>", line 2, column 1:
    &mapping
    ^
found unacceptable key (unhashable type: 'list')
  in "<string>", line 3, column 1:
    &key [ &item a, b, c ]: value
    ^

hs-yaml-json

 na
{"[\"a\",\"b\",\"c\"]":"value"}

java-json

 na
{
  "[a, b, c]": "value"
}

js-json

 na
{
  "[\"a\",\"b\",\"c\"]": "value"
}

js-yaml-json

 na
YAMLException: duplication of an anchor property at line 3, column 1:
    &key [ &item a, b, c ]: value
    ^
    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 readAnchorProperty (/node_modules/js-yaml/lib/js-yaml/loader.js:1209:5)
    at composeNode (/node_modules/js-yaml/lib/js-yaml/loader.js:1298:38)
    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

luajit-json

 na
luajit: /bin/luajit-json:8: Cannot serialise table: table key must be a number or string
stack traceback:
	[C]: in function 'encode'
	/bin/luajit-json:8: in main chunk
	[C]: at 0x004044a0

perl5-pm-json

 na
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 2
   Document: 2
 at /lib/perl5/YAML/Loader.pm line 88.

perl5-pp-json

 na
Line      : 3
Column    : 15
Message   : A node can only have one anchor
Where     : /lib/perl5/YAML/PP/Parser.pm line 775
YAML      : ", b, c ]: value\n"
  at /lib/perl5/YAML/PP/Loader.pm line 59.

perl5-syck-json

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

perl5-tiny-json

 na
YAML::Tiny failed to classify line '&mapping' at /bin/perl5-tiny-json line 12.

perl5-xs-json

 na
{
   "ARRAY(0x271d888)" : "value"
}

perl5-xs-pl

 na
{
  'ARRAY(0x24a95c8)' => 'value'
}

pyyaml-json

 na
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/constructor.py", line 48, in construct_document
    for dummy in generator:
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 398, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 208, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/lib/python2.7/site-packages/yaml/constructor.py", line 132, in construct_mapping
    "found unacceptable key (%s)" % exc, key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<string>", line 2, column 1:
    &mapping
    ^
found unacceptable key (unhashable type: 'list')
  in "<string>", line 3, column 1:
    &key [ &item a, b, c ]: value
    ^

ruamel-json

 na
{
  
}

ruamel-py

 na
{('a', 'b', 'c'): 'value'}

ruby-json

 na
{"[\"a\", \"b\", \"c\"]":"value"}