# YAML Test Matrix

--- &test-W4TN
  Title: Spec Example 9.5. Directives Documents
  Tags: [ 1.3-err, footer, header, spec ]

YAML

%YAML 1.2
--- |
%!PS-Adobe-2.0
...
%YAML 1.2
---
# Empty
...

Expected Events

+STR
+DOC ---
=VAL |%!PS-Adobe-2.0\n
-DOC ...
+DOC ---
=VAL :
-DOC ...
-STR

Expected JSON

"%!PS-Adobe-2.0\n"
null

c-libfyaml-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-ruamel-event

 ok

c-libfyaml-json

 json_ok

hs-hsyaml-json

 json_ok

js-yaml-json

 json_ok

perl-pp-json

 json_ok

py-ruamel-json

 json_ok

cpp-rapidyaml-event

 diff
Minimal Events:
+STR
+DOC ---
=VAL :%!PS-Adobe-2.0\n
-DOC ...
+DOC ---
=VAL :
-DOC ...
-STR
Transformed Events:
+STR
+DOC ---
=VAL :%!PS-Adobe-2.0\n
-DOC
+DOC ---
=VAL :
-DOC
-STR
Got Events:
+STR
+DOC ---
=VAL '%!PS-Adobe-2.0\n
-DOC
+DOC ---
=VAL :
-DOC
-STR

cpp-yamlcpp-event

 diff
Minimal Events:
+STR
+DOC
=VAL :%!PS-Adobe-2.0\n
-DOC
+DOC
=VAL :
-DOC
-STR
Transformed Events:
+STR
+DOC
=VAL :
-DOC
+DOC
=VAL :
-DOC
+DOC
=VAL :
-DOC
-STR
Got Events:
+STR
+DOC
=VAL :
-DOC
+DOC
=VAL :
-DOC
+DOC
=VAL :
-DOC
-STR

js-jsyaml-json

 json_diff
"%!PS-Adobe-2.0\n...\n%YAML 1.2\n---\n# Empty\n...\n"

perl-syck-json

 json_diff
"%YAML 1.2 --- | %!PS-Adobe-2.0 ... %YAML 1.2 --- # Empty ..."

perl-tiny-json

 json_diff
"%!PS-Adobe-2.0\n...\n%YAML 1.2\n---\n...\n"

c-libyaml-event

 error
+STR
+DOC ---
=VAL |
Parse error: could not find expected directive name

dotnet-yamldotnet-json

 error
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 5, Col: 1, Idx: 35) - (Line: 6, Col: 4, Idx: 48): Expected 'StreamEnd', got 'DocumentStart' (at Line: 5, Col: 1, Idx: 35).
   at YamlDotNet.Core.ParserExtensions.Require[T](IParser parser)
   at YamlDotNet.Core.ParserExtensions.Consume[T](IParser parser)
   at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)

go-yaml-json

 error
yaml: found incompatible YAML document

lua-lyaml-json

 error
luajit: 2:5: could not find expected directive name
stack traceback:
	[C]: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:306: in function 'error'
	/usr/local/share/lua/5.1/lyaml/init.lua:325: in function 'parse'
	/usr/local/share/lua/5.1/lyaml/init.lua:502: in function 'load'
	/yaml/bin/lua-lyaml-json:6: in main chunk
	[C]: at 0x556f76288ed0

perl-pplibyaml-json

 error
YAML::PP::LibYAML Error: The problem:

    could not find expected directive name

was found at , line: 3, column: 2
while scanning a directive at line: 3, column: 1

perl-pplibyaml-perl

 error
YAML::PP::LibYAML Error: The problem:

    could not find expected directive name

was found at , line: 3, column: 2
while scanning a directive at line: 3, column: 1

perl-xs-json

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

    could not find expected directive name

was found at document: 1, line: 3, column: 2
while scanning a directive at line: 3, column: 1

perl-xs-perl

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

    could not find expected directive name

was found at document: 1, line: 3, column: 2
while scanning a directive at line: 3, column: 1

perl-yaml-json

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 1
   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: 1
   Document: 2
 at /perl5/lib/perl5/YAML/Loader.pm line 88.

py-pyyaml-event

 error
+STR
+DOC ---
=VAL |
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-event", line 7, in <module>
    for event in yaml.parse(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/yaml/__init__.py", line 75, in parse
    while loader.check_event():
          ^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 193, in parse_document_end
    token = self.peek_token()
            ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 129, in peek_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 177, in fetch_more_tokens
    return self.fetch_directive()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 400, in fetch_directive
    self.tokens.append(self.scan_directive())
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 791, in scan_directive
    name = self.scan_directive_name(start_mark)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 815, in scan_directive_name
    raise ScannerError("while scanning a directive", start_mark,
yaml.scanner.ScannerError: while scanning a directive
  in "<unicode string>", line 3, column 1:
    %!PS-Adobe-2.0
    ^
expected alphabetic or numeric character, but found '!'
  in "<unicode string>", line 3, column 2:
    %!PS-Adobe-2.0
     ^

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.12/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
          ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
                                   ^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 27, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 58, in compose_document
    self.get_event()
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 118, in get_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 193, in parse_document_end
    token = self.peek_token()
            ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 129, in peek_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 177, in fetch_more_tokens
    return self.fetch_directive()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 400, in fetch_directive
    self.tokens.append(self.scan_directive())
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 791, in scan_directive
    name = self.scan_directive_name(start_mark)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 815, in scan_directive_name
    raise ScannerError("while scanning a directive", start_mark,
yaml.scanner.ScannerError: while scanning a directive
  in "<unicode string>", line 3, column 1:
    %!PS-Adobe-2.0
    ^
expected alphabetic or numeric character, but found '!'
  in "<unicode string>", line 3, column 2:
    %!PS-Adobe-2.0
     ^

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.12/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
          ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
                                   ^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 27, in get_node
    return self.compose_document()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/composer.py", line 58, in compose_document
    self.get_event()
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 118, in get_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/parser.py", line 193, in parse_document_end
    token = self.peek_token()
            ^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 129, in peek_token
    self.fetch_more_tokens()
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 177, in fetch_more_tokens
    return self.fetch_directive()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 400, in fetch_directive
    self.tokens.append(self.scan_directive())
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 791, in scan_directive
    name = self.scan_directive_name(start_mark)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/yaml/scanner.py", line 815, in scan_directive_name
    raise ScannerError("while scanning a directive", start_mark,
yaml.scanner.ScannerError: while scanning a directive
  in "<unicode string>", line 3, column 1:
    %!PS-Adobe-2.0
    ^
expected alphabetic or numeric character, but found '!'
  in "<unicode string>", line 3, column 2:
    %!PS-Adobe-2.0
     ^

ruby-psych-json

 error
/ruby/gems/psych/lib/psych.rb:458:in `parse': (<unknown>): could not find expected directive name while scanning a directive at line 3 column 1 (Psych::SyntaxError)
	from /ruby/gems/psych/lib/psych.rb:458:in `parse_stream'
	from /ruby/gems/psych/lib/psych.rb:632:in `load_stream'
	from /yaml/bin/ruby-psych-json:6:in `<main>'

rust-yamlrust-event

 error
+STR
+DOC
=VAL |
Error: ScanError { mark: Marker { index: 17, line: 3, col: 1 }, info: "while scanning a directive, could not find expected directive name" }

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 +DIR |
   1    0    0    0 =SYNX|%
   1    1    1    1 =META|YAML
   1    5    5    5 =WSPC|.
   1    6    6    6 =META|1.2
   1    9    9    9 -DIR |
   1    9    9    9 =EOL |\x0a
   2    0   10   10 =HEAD|---
   2    3   13   13 +NODE|
   2    3   13   13 =WSPC|.
   2    4   14   14 +VAL |
   2    4   14   14 =SYNX||
   2    5   15   15 =EOL |\x0a
   3    0   16   16 =TEXT|%!PS-Adobe-2.0
   3   14   30   30 =NEWL|\x0a
   4    0   31   31 -VAL |
   4    0   31   31 -NODE|
   4    0   31   31 -DOC |
   4    0   31   31 =FOOT|...
   4    3   34   34 =EOL |\x0a
   5    0   35   35 +DOC |
   5    0   35   35 +DIR |
   5    0   35   35 =SYNX|%
   5    1   36   36 =META|YAML
   5    5   40   40 =WSPC|.
   5    6   41   41 =META|1.2
   5    9   44   44 -DIR |
   5    9   44   44 =EOL |\x0a
   6    0   45   45 =HEAD|---
   6    3   48   48 +NODE|
   6    3   48   48 +VAL |
   6    3   48   48 -VAL |
   6    3   48   48 -NODE|
   6    3   48   48 =EOL |\x0a
   7    0   49   49 +COMM|
   7    0   49   49 =SYNX|#
   7    1   50   50 =META|.Empty
   7    7   56   56 -COMM|
   7    7   56   56 =EOL |\x0a
   8    0   57   57 -DOC |
   8    0   57   57 =FOOT|...
   8    3   60   60 =EOL |\x0a

perl-pp-perl

 na
'%!PS-Adobe-2.0
'
undef

perl-syck-perl

 na
'%YAML 1.2 --- | %!PS-Adobe-2.0 ... %YAML 1.2 --- # Empty ...'

perl-tiny-perl

 na
'%!PS-Adobe-2.0
...
%YAML 1.2
---
...
'

py-ruamel-py

 na
'%!PS-Adobe-2.0\n'
None