# YAML Test Matrix

--- &test-KK5P
  Title: Various combinations of explicit block mappings
  Tags: [ mapping, sequence ]

YAML

complex1:
  ? - a
complex2:
  ? - a
  : b
complex3:
  ? - a
  : >
    b
complex4:
  ? >
    a
  :
complex5:
  ? - a
  : - b

Expected Events

+STR
+DOC
+MAP
=VAL :complex1
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :
-MAP
=VAL :complex2
+MAP
+SEQ
=VAL :a
-SEQ
=VAL :b
-MAP
=VAL :complex3
+MAP
+SEQ
=VAL :a
-SEQ
=VAL >b\n
-MAP
=VAL :complex4
+MAP
=VAL >a\n
=VAL :
-MAP
=VAL :complex5
+MAP
+SEQ
=VAL :a
-SEQ
+SEQ
=VAL :b
-SEQ
-MAP
-MAP
-DOC
-STR

Expected JSON



cpp-event

 ok

hs-yaml-event

 ok

java-event

 ok

js-event

 ok

libyaml-event

 ok

nimyaml-event

 ok

perl5-pp-event

 ok

pyyaml-event

 ok

ruamel-event

 ok

perl5-pegex-event

 error
Maximum parsing rules reached (1000)

perl5-pm-pl

 error
YAML Error: Unrecognized implicit value '- a'
   Code: YAML_PARSE_ERR_BAD_IMPLICIT
   Line: 3
   Document: 1
 at /lib/perl5/YAML/Loader.pm line 624.

perl5-syck-pl

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

perl5-tiny-pl

 error
YAML::Tiny does not support a feature in line '  ? - a' 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 3:
      ? - a
      ^
found unacceptable key (unhashable type: 'list')
  in "<string>", line 2, column 5:
      ? - a
        ^

hs-yaml-json

 na
{"complex1":{"[\"a\"]":null},"complex2":{"[\"a\"]":"b"},"complex3":{"[\"a\"]":"b\n"},"complex4":{"a\n":null},"complex5":{"[\"a\"]":["b"]}}

java-json

 na
{
  "complex1": {},
  "complex2": {
    "[a]": "b"
  },
  "complex3": {
    "[a]": "b\n"
  },
  "complex4": {},
  "complex5": {
    "[a]": [
      "b"
    ]
  }
}

js-json

 na
{
  "complex1": {
    "[\"a\"]": null
  },
  "complex2": {
    "[\"a\"]": "b"
  },
  "complex3": {
    "[\"a\"]": "b\n"
  },
  "complex4": {
    "a\n": null
  },
  "complex5": {
    "[\"a\"]": [
      "b"
    ]
  }
}

js-yaml-json

 na
{
  "complex1": {
    "a": null
  },
  "complex2": {
    "a": "b"
  },
  "complex3": {
    "a": "b\n"
  },
  "complex4": {
    "a\n": null
  },
  "complex5": {
    "a": [
      "b"
    ]
  }
}

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: Unrecognized implicit value '- a'
   Code: YAML_PARSE_ERR_BAD_IMPLICIT
   Line: 3
   Document: 1
 at /lib/perl5/YAML/Loader.pm line 624.

perl5-pp-json

 na
{
   "complex1" : {
      "['a']" : null
   },
   "complex2" : {
      "['a']" : "b"
   },
   "complex3" : {
      "['a']" : "b\n"
   },
   "complex4" : {
      "a\n" : null
   },
   "complex5" : {
      "['a']" : [
         "b"
      ]
   }
}

perl5-pp-pl

 na
{
  'complex1' => {
                '[\'a\']' => undef
              },
  'complex2' => {
                '[\'a\']' => 'b'
              },
  'complex3' => {
                '[\'a\']' => 'b
'
              },
  'complex4' => {
                'a
' => undef
              },
  'complex5' => {
                '[\'a\']' => [
                               'b'
                             ]
              }
}

perl5-syck-json

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

perl5-tiny-json

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

perl5-xs-json

 na
{
   "complex1" : {
      "ARRAY(0xbf58e8)" : null
   },
   "complex2" : {
      "ARRAY(0xc24250)" : "b"
   },
   "complex3" : {
      "ARRAY(0xbe48e0)" : "b\n"
   },
   "complex4" : {
      "a\n" : null
   },
   "complex5" : {
      "ARRAY(0xbd6a00)" : [
         "b"
      ]
   }
}

perl5-xs-pl

 na
{
  'complex1' => {
                  'ARRAY(0x1d90658)' => undef
                },
  'complex2' => {
                  'ARRAY(0x1d90b98)' => 'b'
                },
  'complex3' => {
                  'ARRAY(0x1dde1f0)' => 'b
'
                },
  'complex4' => {
                  'a
' => undef
                },
  'complex5' => {
                  'ARRAY(0x1fdf780)' => [
                                          'b'
                                        ]
                }
}

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 3:
      ? - a
      ^
found unacceptable key (unhashable type: 'list')
  in "<string>", line 2, column 5:
      ? - a
        ^

ruamel-json

 na
{
  "complex1": {
    
  }, 
  "complex2": {
    
  }, 
  "complex3": {
    
  }, 
  "complex4": {
    "a\n": null
  }, 
  "complex5": {
    
  }
}

ruamel-py

 na
{'complex1': {('a',): None},
 'complex2': {('a',): 'b'},
 'complex3': {('a',): 'b\n'},
 'complex4': {'a\n': None},
 'complex5': {('a',): ['b']}}

ruby-json

 na
{"complex1":{"[\"a\"]":null},"complex2":{"[\"a\"]":"b"},"complex3":{"[\"a\"]":"b\n"},"complex4":{"a\n":null},"complex5":{"[\"a\"]":["b"]}}