# 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-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-event

 ok

java-snakeyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-pplibyaml-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

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

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 130, 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 130, 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
                     ^

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:131: 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)

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.