# YAML Test Matrix

--- &test-BEC7
  Title: Spec Example 6.14. “YAML” directive
  Tags: [ directive, spec ]

YAML

%YAML 1.3 # Attempt parsing
          # with a warning
---
"foo"

Expected Events

+STR
+DOC ---
=VAL "foo
-DOC
-STR

Expected JSON

"foo"

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

rust-yamlrust-event

 ok

c-libfyaml-json

 json_ok

dotnet-yamldotnet-json

 json_ok

hs-hsyaml-json

 json_ok

js-jsyaml-json

 json_ok

js-yaml-json

 json_ok

perl-pp-json

 json_ok

py-pyyaml-json

 json_ok

perl-syck-json

 json_diff
"%YAML 1.3"
"foo"

c-libyaml-event

 error
+STR
Parse error: found incompatible YAML document

go-yaml-json

 error
yaml: found incompatible YAML document

lua-lyaml-json

 error
luajit: 1:1: found incompatible YAML document
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:496: in function 'load'
	/yaml/bin/lua-lyaml-json:6: in main chunk
	[C]: at 0x55dabd332ed0

perl-pplibyaml-json

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

    found incompatible YAML document

was found at 

perl-pplibyaml-perl

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

    found incompatible YAML document

was found at 

perl-tiny-json

 error
YAML::Tiny failed to classify line '"foo"' at /yaml/bin/perl-tiny-json line 12.

perl-tiny-perl

 error
YAML::Tiny failed to classify line '"foo"' at /yaml/bin/perl-tiny-perl line 15.

perl-xs-json

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

    found incompatible YAML document

was found at document: 1

perl-xs-perl

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

    found incompatible YAML document

was found at document: 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-ruamel-event

 error
+STR
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-event", line 9, in <module>
    for event in yaml.parse(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 371, in parse
    while parser.check_event():
          ^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 201, in parse_implicit_document_start
    return self.parse_document_start()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 209, in parse_document_start
    version, tags = self.process_directives()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 321, in process_directives
    self.loader.version = yaml_version
    ^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 847, in version
    assert sval[1] in [1, 2], f'version minor part can only be 2 or 1, got {val}'
           ^^^^^^^^^^^^^^^^^
AssertionError: version minor part can only be 2 or 1, got (1, 3)

py-ruamel-json

 error
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 21, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 475, in load_all
    while constructor.check_data():
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 105, in check_data
    return self.composer.check_node()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 58, in check_node
    return not self.parser.check_event(StreamEndEvent)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 201, in parse_implicit_document_start
    return self.parse_document_start()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 209, in parse_document_start
    version, tags = self.process_directives()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 321, in process_directives
    self.loader.version = yaml_version
    ^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 847, in version
    assert sval[1] in [1, 2], f'version minor part can only be 2 or 1, got {val}'
           ^^^^^^^^^^^^^^^^^
AssertionError: version minor part can only be 2 or 1, got (1, 3)

py-ruamel-py

 error
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-py", line 38, in <module>
    for doc in yaml.load_all(sys.stdin.read()):
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 475, in load_all
    while constructor.check_data():
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/constructor.py", line 105, in check_data
    return self.composer.check_node()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/composer.py", line 58, in check_node
    return not self.parser.check_event(StreamEndEvent)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 141, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 201, in parse_implicit_document_start
    return self.parse_document_start()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 209, in parse_document_start
    version, tags = self.process_directives()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/parser.py", line 321, in process_directives
    self.loader.version = yaml_version
    ^^^^^^^^^^^^^^^^^^^
  File "/python/lib/python3.12/site-packages/ruamel/yaml/main.py", line 847, in version
    assert sval[1] in [1, 2], f'version minor part can only be 2 or 1, got {val}'
           ^^^^^^^^^^^^^^^^^
AssertionError: version minor part can only be 2 or 1, got (1, 3)

ruby-psych-json

 error
/ruby/gems/psych/lib/psych.rb:458:in `parse': (<unknown>): found incompatible YAML document at line 1 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>'

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.3
   1    9    9    9 -DIR |
   1    9    9    9 =WSPC|.
   1   10   10   10 +COMM|
   1   10   10   10 =SYNX|#
   1   11   11   11 =META|.Attempt.parsing
   1   27   27   27 -COMM|
   1   27   27   27 =EOL |\x0a
   2    0   28   28 =WSPC|..........
   2   10   38   38 +COMM|
   2   10   38   38 =SYNX|#
   2   11   39   39 =META|.with.a.warning
   2   26   54   54 -COMM|
   2   26   54   54 =EOL |\x0a
   3    0   55   55 =HEAD|---
   3    3   58   58 =EOL |\x0a
   4    0   59   59 +NODE|
   4    0   59   59 +VAL |
   4    0   59   59 =SYNX|"
   4    1   60   60 =TEXT|foo
   4    4   63   63 =SYNX|"
   4    5   64   64 -VAL |
   4    5   64   64 -NODE|
   4    5   64   64 =EOL |\x0a
   5    0   65   65 -DOC |

perl-pp-perl

 na
'foo'
Unsupported YAML version '%YAML 1.3' at /perl5/lib/perl5/YAML/PP/Lexer.pm line 825, <> line 1.

perl-syck-perl

 na
'%YAML 1.3'
'foo'

py-pyyaml-py

 na
'foo'