# YAML Test Matrix

--- &test-26DV
  Title: Whitespace around colon in mappings
  Tags: [ alias, mapping, whitespace ]

YAML

"top1" : 
  "key1" : &alias1 scalar1
'top2' : 
  'key2' : &alias2 scalar2
top3: &node3 
  *alias1 : scalar3
top4: 
  *alias2 : scalar4
top5   :    
  scalar5
top6: 
  &anchor6 'key6' : scalar6

Expected Events

+STR
+DOC
+MAP
=VAL "top1
+MAP
=VAL "key1
=VAL &alias1 :scalar1
-MAP
=VAL 'top2
+MAP
=VAL 'key2
=VAL &alias2 :scalar2
-MAP
=VAL :top3
+MAP &node3
=ALI *alias1
=VAL :scalar3
-MAP
=VAL :top4
+MAP
=ALI *alias2
=VAL :scalar4
-MAP
=VAL :top5
=VAL :scalar5
=VAL :top6
+MAP
=VAL &anchor6 'key6
=VAL :scalar6
-MAP
-MAP
-DOC
-STR

Expected JSON

{
"top1": {
"key1": "scalar1"
},
"top2": {
"key2": "scalar2"
},
"top3": {
"scalar1": "scalar3"
},
"top4": {
"scalar2": "scalar4"
},
"top5": "scalar5",
"top6": {
"key6": "scalar6"
}
}

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-rapidyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-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

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

go-yaml-json

 json_ok

hs-hsyaml-json

 json_ok

js-yaml-json

 json_ok

lua-lyaml-json

 json_ok

perl-pp-json

 json_ok

perl-pplibyaml-json

 json_ok

perl-syck-json

 json_ok

perl-xs-json

 json_ok

py-pyyaml-json

 json_ok

py-ruamel-json

 json_ok

ruby-psych-json

 json_ok

js-jsyaml-json

 error
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: bad indentation of a mapping entry (12:19)

  9 | top5   :    
 10 |   scalar5
 11 | top6: 
 12 |   &anchor6 'key6' : scalar6
------------------------^
    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 readBlockMapping (/node/node_modules/js-yaml/lib/loader.js:1182:7)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1441: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 (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10) {
  reason: 'bad indentation of a mapping entry',
  mark: {
    name: null,
    buffer: '"top1" : \n' +
      '  "key1" : &alias1 scalar1\n' +
      "'top2' : \n" +
      "  'key2' : &alias2 scalar2\n" +
      'top3: &node3 \n' +
      '  *alias1 : scalar3\n' +
      'top4: \n' +
      '  *alias2 : scalar4\n' +
      'top5   :    \n' +
      '  scalar5\n' +
      'top6: \n' +
      "  &anchor6 'key6' : scalar6\n",
    position: 183,
    line: 11,
    column: 18,
    snippet: '  9 | top5   :    \n' +
      ' 10 |   scalar5\n' +
      ' 11 | top6: \n' +
      " 12 |   &anchor6 'key6' : scalar6\n" +
      '------------------------^'
  }
}

Node.js v20.13.1

perl-yaml-json

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

perl-yaml-perl

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

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 +NODE|
   1    0    0    0 +MAP |
   1    0    0    0 +PAIR|
   1    0    0    0 +NODE|
   1    0    0    0 +VAL |
   1    0    0    0 =SYNX|"
   1    1    1    1 =TEXT|top1
   1    5    5    5 =SYNX|"
   1    6    6    6 -VAL |
   1    6    6    6 -NODE|
   1    6    6    6 =WSPC|.
   1    7    7    7 =SYNX|:
   1    8    8    8 +NODE|
   1    8    8    8 =WSPC|.
   1    9    9    9 =EOL |\x0a
   2    0   10   10 +MAP |
   2    0   10   10 =DENT|..
   2    2   12   12 +PAIR|
   2    2   12   12 +NODE|
   2    2   12   12 +VAL |
   2    2   12   12 =SYNX|"
   2    3   13   13 =TEXT|key1
   2    7   17   17 =SYNX|"
   2    8   18   18 -VAL |
   2    8   18   18 -NODE|
   2    8   18   18 =WSPC|.
   2    9   19   19 =SYNX|:
   2   10   20   20 =WSPC|.
   2   11   21   21 +NODE|
   2   11   21   21 +PROP|
   2   11   21   21 +ANCH|
   2   11   21   21 =SYNX|&
   2   12   22   22 =META|alias1
   2   18   28   28 -ANCH|
   2   18   28   28 -PROP|
   2   18   28   28 =WSPC|.
   2   19   29   29 +VAL |
   2   19   29   29 =TEXT|scalar1
   2   26   36   36 -VAL |
   2   26   36   36 -NODE|
   2   26   36   36 =EOL |\x0a
   3    0   37   37 -PAIR|
   3    0   37   37 -MAP |
   3    0   37   37 -NODE|
   3    0   37   37 -PAIR|
   3    0   37   37 +PAIR|
   3    0   37   37 +NODE|
   3    0   37   37 +VAL |
   3    0   37   37 =SYNX|'
   3    1   38   38 =TEXT|top2
   3    5   42   42 =SYNX|'
   3    6   43   43 -VAL |
   3    6   43   43 -NODE|
   3    6   43   43 =WSPC|.
   3    7   44   44 =SYNX|:
   3    8   45   45 +NODE|
   3    8   45   45 =WSPC|.
   3    9   46   46 =EOL |\x0a
   4    0   47   47 +MAP |
   4    0   47   47 =DENT|..
   4    2   49   49 +PAIR|
   4    2   49   49 +NODE|
   4    2   49   49 +VAL |
   4    2   49   49 =SYNX|'
   4    3   50   50 =TEXT|key2
   4    7   54   54 =SYNX|'
   4    8   55   55 -VAL |
   4    8   55   55 -NODE|
   4    8   55   55 =WSPC|.
   4    9   56   56 =SYNX|:
   4   10   57   57 =WSPC|.
   4   11   58   58 +NODE|
   4   11   58   58 +PROP|
   4   11   58   58 +ANCH|
   4   11   58   58 =SYNX|&
   4   12   59   59 =META|alias2
   4   18   65   65 -ANCH|
   4   18   65   65 -PROP|
   4   18   65   65 =WSPC|.
   4   19   66   66 +VAL |
   4   19   66   66 =TEXT|scalar2
   4   26   73   73 -VAL |
   4   26   73   73 -NODE|
   4   26   73   73 =EOL |\x0a
   5    0   74   74 -PAIR|
   5    0   74   74 -MAP |
   5    0   74   74 -NODE|
   5    0   74   74 -PAIR|
   5    0   74   74 +PAIR|
   5    0   74   74 +NODE|
   5    0   74   74 +VAL |
   5    0   74   74 =TEXT|top3
   5    4   78   78 -VAL |
   5    4   78   78 -NODE|
   5    4   78   78 =SYNX|:
   5    5   79   79 +NODE|
   5    5   79   79 =WSPC|.
   5    6   80   80 +PROP|
   5    6   80   80 +ANCH|
   5    6   80   80 =SYNX|&
   5    7   81   81 =META|node3
   5   12   86   86 -ANCH|
   5   12   86   86 -PROP|
   5   12   86   86 =WSPC|.
   5   13   87   87 =EOL |\x0a
   6    0   88   88 +MAP |
   6    0   88   88 =DENT|..
   6    2   90   90 +PAIR|
   6    2   90   90 +NODE|
   6    2   90   90 +ALI |
   6    2   90   90 =SYNX|*
   6    3   91   91 =META|alias1
   6    9   97   97 -ALI |
   6    9   97   97 -NODE|
   6    9   97   97 =WSPC|.
   6   10   98   98 =SYNX|:
   6   11   99   99 =WSPC|.
   6   12  100  100 +NODE|
   6   12  100  100 +VAL |
   6   12  100  100 =TEXT|scalar3
   6   19  107  107 -VAL |
   6   19  107  107 -NODE|
   6   19  107  107 =EOL |\x0a
   7    0  108  108 -PAIR|
   7    0  108  108 -MAP |
   7    0  108  108 -NODE|
   7    0  108  108 -PAIR|
   7    0  108  108 +PAIR|
   7    0  108  108 +NODE|
   7    0  108  108 +VAL |
   7    0  108  108 =TEXT|top4
   7    4  112  112 -VAL |
   7    4  112  112 -NODE|
   7    4  112  112 =SYNX|:
   7    5  113  113 +NODE|
   7    5  113  113 =WSPC|.
   7    6  114  114 =EOL |\x0a
   8    0  115  115 +MAP |
   8    0  115  115 =DENT|..
   8    2  117  117 +PAIR|
   8    2  117  117 +NODE|
   8    2  117  117 +ALI |
   8    2  117  117 =SYNX|*
   8    3  118  118 =META|alias2
   8    9  124  124 -ALI |
   8    9  124  124 -NODE|
   8    9  124  124 =WSPC|.
   8   10  125  125 =SYNX|:
   8   11  126  126 =WSPC|.
   8   12  127  127 +NODE|
   8   12  127  127 +VAL |
   8   12  127  127 =TEXT|scalar4
   8   19  134  134 -VAL |
   8   19  134  134 -NODE|
   8   19  134  134 =EOL |\x0a
   9    0  135  135 -PAIR|
   9    0  135  135 -MAP |
   9    0  135  135 -NODE|
   9    0  135  135 -PAIR|
   9    0  135  135 +PAIR|
   9    0  135  135 +NODE|
   9    0  135  135 +VAL |
   9    0  135  135 =TEXT|top5
   9    4  139  139 -VAL |
   9    4  139  139 -NODE|
   9    4  139  139 =WSPC|...
   9    7  142  142 =SYNX|:
   9    8  143  143 =WSPC|....
   9   12  147  147 =EOL |\x0a
  10    0  148  148 =DENT|.
  10    1  149  149 =WSPC|.
  10    2  150  150 +NODE|
  10    2  150  150 +VAL |
  10    2  150  150 =TEXT|scalar5
  10    9  157  157 -VAL |
  10    9  157  157 -NODE|
  10    9  157  157 =EOL |\x0a
  11    0  158  158 -PAIR|
  11    0  158  158 +PAIR|
  11    0  158  158 +NODE|
  11    0  158  158 +VAL |
  11    0  158  158 =TEXT|top6
  11    4  162  162 -VAL |
  11    4  162  162 -NODE|
  11    4  162  162 =SYNX|:
  11    5  163  163 +NODE|
  11    5  163  163 =WSPC|.
  11    6  164  164 =EOL |\x0a
  12    0  165  165 +MAP |
  12    0  165  165 =DENT|..
  12    2  167  167 +PAIR|
  12    2  167  167 +NODE|
  12    2  167  167 +PROP|
  12    2  167  167 +ANCH|
  12    2  167  167 =SYNX|&
  12    3  168  168 =META|anchor6
  12   10  175  175 -ANCH|
  12   10  175  175 -PROP|
  12   10  175  175 =WSPC|.
----- 8< -----

perl-pp-perl

 na
{
  'top1' => {
              'key1' => 'scalar1'
            },
  'top2' => {
              'key2' => 'scalar2'
            },
  'top3' => {
              'scalar1' => 'scalar3'
            },
  'top4' => {
              'scalar2' => 'scalar4'
            },
  'top5' => 'scalar5',
  'top6' => {
              'key6' => 'scalar6'
            }
}

perl-pplibyaml-perl

 na
{
  'top1' => {
              'key1' => 'scalar1'
            },
  'top2' => {
              'key2' => 'scalar2'
            },
  'top3' => {
              'scalar1' => 'scalar3'
            },
  'top4' => {
              'scalar2' => 'scalar4'
            },
  'top5' => 'scalar5',
  'top6' => {
              'key6' => 'scalar6'
            }
}

perl-syck-perl

 na
{
  'top1' => {
              'key1' => 'scalar1'
            },
  'top2' => {
              'key2' => 'scalar2'
            },
  'top3' => {
              'scalar1' => 'scalar3'
            },
  'top4' => {
              'scalar2' => 'scalar4'
            },
  'top5' => 'scalar5',
  'top6' => {
              'key6' => 'scalar6'
            }
}

perl-xs-perl

 na
{
  'top1' => {
              'key1' => 'scalar1'
            },
  'top2' => {
              'key2' => 'scalar2'
            },
  'top3' => {
              'scalar1' => 'scalar3'
            },
  'top4' => {
              'scalar2' => 'scalar4'
            },
  'top5' => 'scalar5',
  'top6' => {
              'key6' => 'scalar6'
            }
}

py-pyyaml-py

 na
{'top1': {'key1': 'scalar1'},
 'top2': {'key2': 'scalar2'},
 'top3': {'scalar1': 'scalar3'},
 'top4': {'scalar2': 'scalar4'},
 'top5': 'scalar5',
 'top6': {'key6': 'scalar6'}}

py-ruamel-py

 na
{'top1': {'key1': 'scalar1'},
 'top2': {'key2': 'scalar2'},
 'top3': {'scalar1': 'scalar3'},
 'top4': {'scalar2': 'scalar4'},
 'top5': 'scalar5',
 'top6': {'key6': 'scalar6'}}

perl-tiny-json

 ni
YAML::Tiny does not support a feature in line '&alias1 scalar1' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

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