# YAML Test Matrix

--- &test-CXX2
  Title: Mapping with anchor on document start line
  Tags: [ anchor, header, mapping ]

YAML

--- &anchor a: b

Expected Events

+STR
+DOC ---
+MAP
=VAL &anchor :a
=VAL :b
-MAP
-DOC
-STR

Expected JSON

{
"a": "b"
}

nimyaml-event

 ok

perl5-pegex-event

 ok

perl5-pp-event

 ok

perl5-pp-json

 json_ok

perl5-syck-json

 json_ok

perl5-pm-json

 json_diff
"a: b"

cpp-event

 error
+STR
+DOC
=VAL &1 :a
-DOC
terminate called after throwing an instance of 'YAML::ParserException'
  what():  yaml-cpp: error at line 1, column 14: illegal map value
timeout: the monitored command dumped core

hs-yaml-event

 error
+STR
+DOC ---
=VAL :
parsing error near byte offset Pos {posByteOffset = 3, posCharOffset = 3, posLine = 1, posColumn = 3} (Lexical error near " &anchor a: b")

hs-yaml-json

 error
hsyaml-parser: user error (:1:3: Lexical error near " &anchor a: b")

java-event

 error
Exception in thread "main" mapping values are not allowed here
 in 'reader', line 1, column 14:
    --- &anchor a: b
                 ^

	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchValue(ScannerImpl.java:870)
	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:358)
	at org.yaml.snakeyaml.scanner.ScannerImpl.peekToken(ScannerImpl.java:250)
	at org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentEnd.produce(ParserImpl.java:253)
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
	at org.yaml.snakeyaml.Yaml$3.hasNext(Yaml.java:711)
	at org.yaml.editor.Snake2Events.yamlToEvents(Snake2Events.java:110)
	at org.yaml.editor.Snake2Events.main(Snake2Events.java:118)

java-json

 error
Exception in thread "main" mapping values are not allowed here
 in 'reader', line 1, column 14:
    --- &anchor a: b
                 ^

	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchValue(ScannerImpl.java:870)
	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:358)
	at org.yaml.snakeyaml.scanner.ScannerImpl.peekToken(ScannerImpl.java:250)
	at org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentEnd.produce(ParserImpl.java:253)
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
	at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:168)
	at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:87)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:123)
	at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:547)
	at org.yaml.editor.Snake2Json.yamlToJson(Snake2Json.java:18)
	at org.yaml.editor.Snake2Json.main(Snake2Json.java:25)

js-yaml-json

 error
YAMLException: end of the stream or a document separator is expected at line 1, column 14:
    --- &anchor a: b
                 ^
    at generateError (/node_modules/js-yaml/lib/js-yaml/loader.js:165:10)
    at throwError (/node_modules/js-yaml/lib/js-yaml/loader.js:171:9)
    at readDocument (/node_modules/js-yaml/lib/js-yaml/loader.js:1512:5)
    at loadDocuments (/node_modules/js-yaml/lib/js-yaml/loader.js:1548:5)
    at Object.loadAll (/node_modules/js-yaml/lib/js-yaml/loader.js:1556:19)
    at Object.<anonymous> (/bin/js-yaml-json:6:6)
    at Object.<anonymous> (/bin/js-yaml-json:3:1)
    at Module._compile (module.js:410:26)
    at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:173:23)
    at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
    at compilePath (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
    at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
    at Object.<anonymous> (/usr/local/lib/node_modules/coffee-script/bin/coffee:15:45)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

libyaml-event

 error
+STR
+DOC ---
=VAL &anchor :a
Parse error: mapping values are not allowed in this context

luajit-json

 error
luajit: mapping values are not allowed in this context at document: 1, line: 1, column: 14

stack traceback:
	[C]: in function 'load'
	/bin/luajit-json:6: in main chunk
	[C]: at 0x004044a0

perl5-tiny-json

 error
YAML::Tiny does not support a feature in line '&anchor a: b' at /bin/perl5-tiny-json line 12.

perl5-tiny-pl

 error
YAML::Tiny does not support a feature in line '&anchor a: b' at /bin/perl5-tiny-pl line 15.

perl5-xs-json

 error
YAML::XS::Load Error: The problem:

    mapping values are not allowed in this context

was found at document: 1, line: 1, column: 14

perl5-xs-pl

 error
YAML::XS::Load Error: The problem:

    mapping values are not allowed in this context

was found at document: 1, line: 1, column: 14

pyyaml-event

 error
+STR
+DOC ---
=VAL &anchor :a
Traceback (most recent call last):
  File "/bin/pyyaml-event", line 7, in <module>
    for event in yaml.parse(sys.stdin.read()):
  File "/lib/python2.7/site-packages/yaml/__init__.py", line 36, in parse
    while loader.check_event():
  File "/lib/python2.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/lib/python2.7/site-packages/yaml/parser.py", line 193, in parse_document_end
    token = self.peek_token()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 129, in peek_token
    self.fetch_more_tokens()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 579, in fetch_value
    self.get_mark())
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<string>", line 1, column 14:
    --- &anchor a: b
                 ^

pyyaml-json

 error
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/composer.py", line 27, in get_node
    return self.compose_document()
  File "/lib/python2.7/site-packages/yaml/composer.py", line 58, in compose_document
    self.get_event()
  File "/lib/python2.7/site-packages/yaml/parser.py", line 118, in get_event
    self.current_event = self.state()
  File "/lib/python2.7/site-packages/yaml/parser.py", line 193, in parse_document_end
    token = self.peek_token()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 129, in peek_token
    self.fetch_more_tokens()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 579, in fetch_value
    self.get_mark())
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<string>", line 1, column 14:
    --- &anchor a: b
                 ^

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/composer.py", line 27, in get_node
    return self.compose_document()
  File "/lib/python2.7/site-packages/yaml/composer.py", line 58, in compose_document
    self.get_event()
  File "/lib/python2.7/site-packages/yaml/parser.py", line 118, in get_event
    self.current_event = self.state()
  File "/lib/python2.7/site-packages/yaml/parser.py", line 193, in parse_document_end
    token = self.peek_token()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 129, in peek_token
    self.fetch_more_tokens()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/lib/python2.7/site-packages/yaml/scanner.py", line 579, in fetch_value
    self.get_mark())
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<string>", line 1, column 14:
    --- &anchor a: b
                 ^

ruamel-event

 error
+STR
+DOC ---
=VAL &anchor :a
Traceback (most recent call last):
  File "/bin/ruamel-event", line 7, in <module>
    for event in ruamel.yaml.parse(sys.stdin.read()):
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/main.py", line 595, in parse
    while loader._parser.check_event():
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/parser.py", line 144, in check_event
    self.current_event = self.state()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/parser.py", line 244, in parse_document_end
    token = self.scanner.peek_token()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 173, in peek_token
    self.fetch_more_tokens()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 273, in fetch_more_tokens
    return self.fetch_value()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 626, in fetch_value
    self.reader.get_mark())
ruamel.yaml.scanner.ScannerError: mapping values are not allowed here
  in "<byte string>", line 1, column 14:
    --- &anchor a: b
                 ^ (line: 1)

ruamel-json

 error
Traceback (most recent call last):
  File "/bin/ruamel-json", line 19, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/main.py", line 656, in load_all
    yield loader._constructor.get_data()  # type: ignore
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/constructor.py", line 97, in get_data
    return self.construct_document(self.composer.get_node())
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py", line 65, in get_node
    return self.compose_document()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py", line 99, in compose_document
    self.parser.get_event()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/parser.py", line 166, in get_event
    self.current_event = self.state()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/parser.py", line 244, in parse_document_end
    token = self.scanner.peek_token()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 173, in peek_token
    self.fetch_more_tokens()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 273, in fetch_more_tokens
    return self.fetch_value()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 626, in fetch_value
    self.reader.get_mark())
ruamel.yaml.scanner.ScannerError: mapping values are not allowed here
  in "<byte string>", line 1, column 14:
    --- &anchor a: b
                 ^ (line: 1)

ruamel-py

 error
Traceback (most recent call last):
  File "/bin/ruamel-py", line 36, in <module>
    for doc in ruamel.yaml.load_all(sys.stdin.read(), Loader=ruamel.yaml.Loader):
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/main.py", line 656, in load_all
    yield loader._constructor.get_data()  # type: ignore
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/constructor.py", line 97, in get_data
    return self.construct_document(self.composer.get_node())
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py", line 65, in get_node
    return self.compose_document()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/composer.py", line 99, in compose_document
    self.parser.get_event()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/parser.py", line 166, in get_event
    self.current_event = self.state()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/parser.py", line 244, in parse_document_end
    token = self.scanner.peek_token()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 173, in peek_token
    self.fetch_more_tokens()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 273, in fetch_more_tokens
    return self.fetch_value()
  File "/usr/local/lib/python2.7/dist-packages/ruamel/yaml/scanner.py", line 626, in fetch_value
    self.reader.get_mark())
ruamel.yaml.scanner.ScannerError: mapping values are not allowed here
  in "<byte string>", line 1, column 14:
    --- &anchor a: b
                 ^ (line: 1)

ruby-json

 error
/usr/lib/ruby/2.3.0/psych.rb:380:in `parse': (<unknown>): mapping values are not allowed in this context at line 1 column 14 (Psych::SyntaxError)
	from /usr/lib/ruby/2.3.0/psych.rb:380:in `parse_stream'
	from /usr/lib/ruby/2.3.0/psych.rb:463:in `load_stream'
	from /bin/ruby-json:6:in `<main>'

perl5-pm-pl

 na
'a: b'

perl5-pp-pl

 na
{
  'a' => 'b'
}

perl5-syck-pl

 na
{
  'a' => 'b'
}