# YAML Test Matrix

--- &test-3GZX
  Title: Spec Example 7.1. Alias Nodes
  Tags: [ alias, mapping, spec ]

YAML

First occurrence: &anchor Foo
Second occurrence: *anchor
Override anchor: &anchor Bar
Reuse anchor: *anchor

Expected Events

+STR
+DOC
+MAP
=VAL :First occurrence
=VAL &anchor :Foo
=VAL :Second occurrence
=ALI *anchor
=VAL :Override anchor
=VAL &anchor :Bar
=VAL :Reuse anchor
=ALI *anchor
-MAP
-DOC
-STR

Expected JSON

{
"First occurrence": "Foo",
"Override anchor": "Bar",
"Reuse anchor": "Bar",
"Second occurrence": "Foo"
}

c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-rapidyaml-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

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

go-yaml-json

 json_ok

hs-hsyaml-json

 json_ok

java-snakeengine-json

 json_ok

java-snakeyaml-json

 json_ok

js-jsyaml-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

perl-yaml-json

 json_ok

py-ruamel-json

 json_ok

raku-yamlish-json

 json_ok

ruby-psych-json

 json_ok

py-pyyaml-json

 error
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/composer.py", line 27, in get_node
    return self.compose_document()
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 77, in compose_node
    "second occurrence", event.start_mark)
yaml.composer.ComposerError: found duplicate anchor 'anchor'; first occurrence
  in "<unicode string>", line 1, column 19:
    First occurrence: &anchor Foo
                      ^
second occurrence
  in "<unicode string>", line 3, column 18:
    Override anchor: &anchor Bar
                     ^

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/composer.py", line 27, in get_node
    return self.compose_document()
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/python/lib/python3.7/site-packages/yaml/composer.py", line 77, in compose_node
    "second occurrence", event.start_mark)
yaml.composer.ComposerError: found duplicate anchor 'anchor'; first occurrence
  in "<unicode string>", line 1, column 19:
    First occurrence: &anchor Foo
                      ^
second occurrence
  in "<unicode string>", line 3, column 18:
    Override anchor: &anchor Bar
                     ^

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 =TEXT|First.occurrence
   1   16   16   16 -VAL |
   1   16   16   16 -NODE|
   1   16   16   16 =SYNX|:
   1   17   17   17 =WSPC|.
   1   18   18   18 +NODE|
   1   18   18   18 +PROP|
   1   18   18   18 +ANCH|
   1   18   18   18 =SYNX|&
   1   19   19   19 =META|anchor
   1   25   25   25 -ANCH|
   1   25   25   25 -PROP|
   1   25   25   25 =WSPC|.
   1   26   26   26 +VAL |
   1   26   26   26 =TEXT|Foo
   1   29   29   29 -VAL |
   1   29   29   29 -NODE|
   1   29   29   29 =EOL |\x0a
   2    0   30   30 -PAIR|
   2    0   30   30 +PAIR|
   2    0   30   30 +NODE|
   2    0   30   30 +VAL |
   2    0   30   30 =TEXT|Second.occurrence
   2   17   47   47 -VAL |
   2   17   47   47 -NODE|
   2   17   47   47 =SYNX|:
   2   18   48   48 =WSPC|.
   2   19   49   49 +NODE|
   2   19   49   49 +ALI |
   2   19   49   49 =SYNX|*
   2   20   50   50 =META|anchor
   2   26   56   56 -ALI |
   2   26   56   56 -NODE|
   2   26   56   56 =EOL |\x0a
   3    0   57   57 -PAIR|
   3    0   57   57 +PAIR|
   3    0   57   57 +NODE|
   3    0   57   57 +VAL |
   3    0   57   57 =TEXT|Override.anchor
   3   15   72   72 -VAL |
   3   15   72   72 -NODE|
   3   15   72   72 =SYNX|:
   3   16   73   73 =WSPC|.
   3   17   74   74 +NODE|
   3   17   74   74 +PROP|
   3   17   74   74 +ANCH|
   3   17   74   74 =SYNX|&
   3   18   75   75 =META|anchor
   3   24   81   81 -ANCH|
   3   24   81   81 -PROP|
   3   24   81   81 =WSPC|.
   3   25   82   82 +VAL |
   3   25   82   82 =TEXT|Bar
   3   28   85   85 -VAL |
   3   28   85   85 -NODE|
   3   28   85   85 =EOL |\x0a
   4    0   86   86 -PAIR|
   4    0   86   86 +PAIR|
   4    0   86   86 +NODE|
   4    0   86   86 +VAL |
   4    0   86   86 =TEXT|Reuse.anchor
   4   12   98   98 -VAL |
   4   12   98   98 -NODE|
   4   12   98   98 =SYNX|:
   4   13   99   99 =WSPC|.
   4   14  100  100 +NODE|
   4   14  100  100 +ALI |
   4   14  100  100 =SYNX|*
   4   15  101  101 =META|anchor
   4   21  107  107 -ALI |
   4   21  107  107 -NODE|
   4   21  107  107 =EOL |\x0a
   5    0  108  108 -PAIR|
   5    0  108  108 -MAP |
   5    0  108  108 -NODE|
   5    0  108  108 -DOC |

perl-pp-perl

 na
{
  'First occurrence' => 'Foo',
  'Override anchor' => 'Bar',
  'Reuse anchor' => 'Bar',
  'Second occurrence' => 'Foo'
}

perl-pplibyaml-perl

 na
{
  'First occurrence' => 'Foo',
  'Override anchor' => 'Bar',
  'Reuse anchor' => 'Bar',
  'Second occurrence' => 'Foo'
}

perl-syck-perl

 na
{
  'First occurrence' => 'Foo',
  'Override anchor' => 'Bar',
  'Reuse anchor' => 'Bar',
  'Second occurrence' => 'Foo'
}

perl-xs-perl

 na
{
  'First occurrence' => 'Foo',
  'Override anchor' => 'Bar',
  'Reuse anchor' => ${\$VAR1->{'Override anchor'}},
  'Second occurrence' => ${\$VAR1->{'First occurrence'}}
}

perl-yaml-perl

 na
{
  'First occurrence' => 'Foo',
  'Override anchor' => 'Bar',
  'Reuse anchor' => 'Bar',
  'Second occurrence' => 'Foo'
}

py-ruamel-py

 na
{'First occurrence': 'Foo',
 'Override anchor': 'Bar',
 'Reuse anchor': 'Bar',
 'Second occurrence': 'Foo'}
/python/lib/python3.7/site-packages/ruamel/yaml/composer.py:136: ReusedAnchorWarning: 
found duplicate anchor 'anchor'
first occurrence   in "<unicode string>", line 1, column 19:
    First occurrence: &anchor Foo
                      ^ (line: 1)
second occurrence   in "<unicode string>", line 3, column 18:
    Override anchor: &anchor Bar
                     ^ (line: 3)
  warnings.warn(ws, ReusedAnchorWarning)

raku-yamlish-raku

 na
{
  First occurrence  => "Foo".Str,
  Override anchor   => "Bar".Str,
  Reuse anchor      => "Bar".Str,
  Second occurrence => "Foo".Str,
}

perl-tiny-json

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

perl-tiny-perl

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