# YAML Test Matrix

--- &test-V9D5
  Title: Spec Example 8.19. Compact Block Mappings
  Tags: [ complex-key, explicit-key, mapping, spec ]

YAML

- sun: yellow
- ? earth: blue
  : moon: white

Expected Events

+STR
+DOC
+SEQ
+MAP
=VAL :sun
=VAL :yellow
-MAP
+MAP
+MAP
=VAL :earth
=VAL :blue
-MAP
+MAP
=VAL :moon
=VAL :white
-MAP
-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-snakeengine-event

 ok

java-snakeyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

rust-yamlrust-event

 ok

cpp-rapidyaml-event

 diff
Minimal Events:
+STR
+DOC
+SEQ
+MAP
=VAL :sun
=VAL :yellow
-MAP
+MAP
+MAP
=VAL :earth
=VAL :blue
-MAP
+MAP
=VAL :moon
=VAL :white
-MAP
-MAP
-SEQ
-DOC
-STR
Transformed Events:
+STR
+DOC
+SEQ
+MAP
=VAL :sun
=VAL :yellow
-MAP
+MAP
=VAL :earth
=VAL :blue
=VAL :
=VAL :moon: white
-MAP
-SEQ
-DOC
-STR
Got Events:
+STR
+DOC
+SEQ
+MAP
=VAL :sun
=VAL :yellow
-MAP
+MAP
=VAL :earth
=VAL :blue
=VAL :
=VAL :moon: white
-MAP
-SEQ
-DOC
-STR

perl-syck-perl

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

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.7/site-packages/yaml/__init__.py", line 93, in load_all
    yield loader.get_data()
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 142, in construct_mapping
    "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 3:
    - ? earth: blue
      ^
found unhashable key
  in "<unicode string>", line 2, column 5:
    - ? earth: blue
        ^

py-ruamel-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-py", line 36, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/main.py", line 1097, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 114, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 131, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 674, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 445, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 258, in construct_mapping
    key_node.start_mark,
ruamel.yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 3:
    - ? earth: blue
      ^ (line: 2)
found unhashable key
  in "<unicode string>", line 2, column 5:
    - ? earth: blue
        ^ (line: 2)

raku-yamlish-raku

 error
Couldn't parse YAML
  in sub load-yamls at /raku/sources/44795C7AB0F35700F4CA9C3E2CC5C924EE4C608F (YAMLish) line 959
  in block <unit> at /yaml/bin/raku-yamlish-raku line 6

c-libfyaml-json

 na
[
  {
    "sun": "yellow"
  },
  {
]
stdin:2:5: error: Non scalar keys are not allowed in JSON emit mode
- ? earth: blue
    ^~~~~~~~~~~
  : moon: white
~~

dotnet-yamldotnet-json

 na
[{"sun": "yellow"}, {? {"earth": "blue"} : {"moon": "white"}}]

go-yaml-json

 na
yaml: invalid map key: map[interface {}]interface {}{"earth":"blue"}

hs-hsyaml-json

 na
[{"sun":"yellow"},{"{\"earth\":\"blue\"}":{"moon":"white"}}]

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 =DENT|.
   1    2    2    2 +NODE|
   1    2    2    2 +MAP |
   1    2    2    2 +PAIR|
   1    2    2    2 +NODE|
   1    2    2    2 +VAL |
   1    2    2    2 =TEXT|sun
   1    5    5    5 -VAL |
   1    5    5    5 -NODE|
   1    5    5    5 =SYNX|:
   1    6    6    6 =WSPC|.
   1    7    7    7 +NODE|
   1    7    7    7 +VAL |
   1    7    7    7 =TEXT|yellow
   1   13   13   13 -VAL |
   1   13   13   13 -NODE|
   1   13   13   13 =EOL |\x0a
   2    0   14   14 -PAIR|
   2    0   14   14 -MAP |
   2    0   14   14 -NODE|
   2    0   14   14 =SYNX|-
   2    1   15   15 =DENT|.
   2    2   16   16 +NODE|
   2    2   16   16 +MAP |
   2    2   16   16 +PAIR|
   2    2   16   16 =SYNX|?
   2    3   17   17 =DENT|.
   2    4   18   18 +NODE|
   2    4   18   18 +MAP |
   2    4   18   18 +PAIR|
   2    4   18   18 +NODE|
   2    4   18   18 +VAL |
   2    4   18   18 =TEXT|earth
   2    9   23   23 -VAL |
   2    9   23   23 -NODE|
   2    9   23   23 =SYNX|:
   2   10   24   24 =WSPC|.
   2   11   25   25 +NODE|
   2   11   25   25 +VAL |
   2   11   25   25 =TEXT|blue
   2   15   29   29 -VAL |
   2   15   29   29 -NODE|
   2   15   29   29 =EOL |\x0a
   3    0   30   30 -PAIR|
   3    0   30   30 -MAP |
   3    0   30   30 -NODE|
   3    0   30   30 =DENT|..
   3    2   32   32 =SYNX|:
   3    3   33   33 =DENT|.
   3    4   34   34 +NODE|
   3    4   34   34 +MAP |
   3    4   34   34 +PAIR|
   3    4   34   34 +NODE|
   3    4   34   34 +VAL |
   3    4   34   34 =TEXT|moon
   3    8   38   38 -VAL |
   3    8   38   38 -NODE|
   3    8   38   38 =SYNX|:
   3    9   39   39 =WSPC|.
   3   10   40   40 +NODE|
   3   10   40   40 +VAL |
   3   10   40   40 =TEXT|white
   3   15   45   45 -VAL |
   3   15   45   45 -NODE|
   3   15   45   45 =EOL |\x0a
   4    0   46   46 -PAIR|
   4    0   46   46 -MAP |
   4    0   46   46 -NODE|
   4    0   46   46 -PAIR|
   4    0   46   46 -MAP |
   4    0   46   46 -NODE|
   4    0   46   46 -SEQ |
   4    0   46   46 -NODE|
   4    0   46   46 -DOC |

java-snakeengine-json

 na
[
  {
    "sun": "yellow"
  },
  {
    "{earth\u003dblue}": {
      "moon": "white"
    }
  }
]

java-snakeyaml-json

 na
[
  {
    "sun": "yellow"
  },
  {
    "{earth\u003dblue}": {
      "moon": "white"
    }
  }
]

js-jsyaml-json

 na
[{"sun":"yellow"},{"[object Object]":{"moon":"white"}}]

js-yaml-json

 na
[
  {
    "sun": "yellow"
  },
  {
    "{ earth: blue }": {
      "moon": "white"
    }
  }
]
(node:3936) Warning: Keys with collection values will be stringified due to JS Object restrictions: "{ earth: blue }". Set mapAsMap: true to use object keys.

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

perl-pp-json

 na
[
   {
      "sun" : "yellow"
   },
   {
      "{earth => 'blue'}" : {
         "moon" : "white"
      }
   }
]

perl-pp-perl

 na
[
  {
    'sun' => 'yellow'
  },
  {
    '{earth => \'blue\'}' => {
                               'moon' => 'white'
                             }
  }
]

perl-pplibyaml-json

 na
[
   {
      "sun" : "yellow"
   },
   {
      "{earth => 'blue'}" : {
         "moon" : "white"
      }
   }
]

perl-pplibyaml-perl

 na
[
  {
    'sun' => 'yellow'
  },
  {
    '{earth => \'blue\'}' => {
                               'moon' => 'white'
                             }
  }
]

perl-syck-json

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

perl-tiny-json

 na
YAML::Tiny found illegal characters in plain scalar: '? earth: blue' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
[
   {
      "sun" : "yellow"
   },
   {
      "HASH(0x5601dc6a1408)" : {
         "moon" : "white"
      }
   }
]

perl-xs-perl

 na
[
  {
    'sun' => 'yellow'
  },
  {
    'HASH(0x5629ae512f00)' => {
                                'moon' => 'white'
                              }
  }
]

perl-yaml-json

 na
[
   {
      "sun" : "yellow"
   },
   {
      "earth: blue" : "moon: white"
   }
]

perl-yaml-perl

 na
[
  {
    'sun' => 'yellow'
  },
  {
    'earth: blue' => 'moon: white'
  }
]

py-pyyaml-json

 na
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.7/site-packages/yaml/__init__.py", line 93, in load_all
    yield loader.get_data()
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
  File "/python/lib/python3.7/site-packages/yaml/constructor.py", line 142, in construct_mapping
    "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 3:
    - ? earth: blue
      ^
found unhashable key
  in "<unicode string>", line 2, column 5:
    - ? earth: blue
        ^

py-ruamel-json

 na
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 19, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/python/lib/python3.7/site-packages/ruamel/yaml/main.py", line 1097, in load_all
    yield loader._constructor.get_data()
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 114, in get_data
    return self.construct_document(self.composer.get_node())
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 131, in construct_document
    for _dummy in generator:
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 674, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 445, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/python/lib/python3.7/site-packages/ruamel/yaml/constructor.py", line 258, in construct_mapping
    key_node.start_mark,
ruamel.yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 3:
    - ? earth: blue
      ^ (line: 2)
found unhashable key
  in "<unicode string>", line 2, column 5:
    - ? earth: blue
        ^ (line: 2)

raku-yamlish-json

 na
Couldn't parse YAML
  in sub load-yamls at /raku/sources/44795C7AB0F35700F4CA9C3E2CC5C924EE4C608F (YAMLish) line 959
  in block <unit> at /yaml/bin/raku-yamlish-json line 6

ruby-psych-json

 na
[{"sun":"yellow"},{"{\"earth\"=>\"blue\"}":{"moon":"white"}}]

perl-tiny-perl

 ni
YAML::Tiny found illegal characters in plain scalar: '? earth: blue' at /yaml/bin/perl-tiny-perl line 15.