xref: /freebsd/contrib/libyaml/tests/ReadMe.md (revision 24e4dcf4ba5e9dedcf89efd358ea3e1fe5867020)
1# Testing the Parser and Emitter
2
3There are several programs to test the parser and emitter.
4
5## Parser
6
7    echo 'foo: bar' | ./tests/run-parser-test-suite
8
9This will output the parsing events in yaml-test-suite format:
10
11    +STR
12    +DOC
13    +MAP
14    =VAL :foo
15    =VAL :bar
16    -MAP
17    -DOC
18    -STR
19
20For flow style events, you have to enable it with the `--flow` option:
21
22    echo '{ foo: bar }' | ./tests/run-parser-test-suite --flow keep
23
24    ...
25    +MAP {}
26    ...
27
28In the future, this will be the default.
29
30You can also explicitly disable this style with `--flow off`, or output
31flow style always, with `--flow on`.
32
33## Emitter
34
35run-emitter-test-suite takes yaml-test-suite event format and emits YAML.
36
37    ./tests/run-parser-test-suite ... | ./tests/run-emitter-test-suite
38
39## Options
40
41* `--directive (1.1|1.2)`
42
43  Prints a version directive before every document.
44
45* `--flow on`
46
47  Will emit the whole document in flow style.
48
49* `--flow off`
50
51  Will emit the whole document in block style.
52
53* `--flow keep`
54
55  Will emit block/flow style like in the original document.
56
57Example:
58```
59% echo 'foo: [bar, {x: y}]' |
60  ./tests/run-parser-test-suite --flow keep |
61  ./tests/run-emitter-test-suite --flow keep
62foo: [bar, {x: y}]
63```
64