diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/TESTS.md | 16 | ||||
-rw-r--r-- | docs/TOOLS.md | 10 |
2 files changed, 23 insertions, 3 deletions
diff --git a/docs/TESTS.md b/docs/TESTS.md index 8005ec9da..db06dbebc 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md | |||
@@ -19,12 +19,26 @@ files to have the same name except for the leading number. In general, | |||
19 | test suite should be append-only: old tests should not be modified, | 19 | test suite should be append-only: old tests should not be modified, |
20 | new tests should be created instead. | 20 | new tests should be created instead. |
21 | 21 | ||
22 | |||
23 | Note that only `ok` tests are normative: `err` tests test error | 22 | Note that only `ok` tests are normative: `err` tests test error |
24 | recovery and it is totally ok for a parser to not implement any error | 23 | recovery and it is totally ok for a parser to not implement any error |
25 | recovery at all. However, for libsyntax2.0 we do care about error | 24 | recovery at all. However, for libsyntax2.0 we do care about error |
26 | recovery, and we do care about precise and useful error messages. | 25 | recovery, and we do care about precise and useful error messages. |
27 | 26 | ||
27 | There are also so-called "inline tests". They appear as the comments | ||
28 | with a `test` header in the source code, like this: | ||
29 | |||
30 | ```rust | ||
31 | // test fn_basic | ||
32 | // fn foo() {} | ||
33 | fn fn_item(p: &mut Parser) { | ||
34 | // ... | ||
35 | } | ||
36 | ``` | ||
37 | |||
38 | You can run `cargo collect-tests` command to collect all inline tests | ||
39 | into `tests/data/inline` directory. The main advantage of inline tests | ||
40 | is that they help to illustrate what the relevant code is doing. | ||
41 | |||
28 | 42 | ||
29 | Contribution opportunity: design and implement testing infrastructure | 43 | Contribution opportunity: design and implement testing infrastructure |
30 | for validators. | 44 | for validators. |
diff --git a/docs/TOOLS.md b/docs/TOOLS.md index 1fcfa2dec..f8754c06f 100644 --- a/docs/TOOLS.md +++ b/docs/TOOLS.md | |||
@@ -17,14 +17,20 @@ cargo tool | |||
17 | ``` | 17 | ``` |
18 | 18 | ||
19 | 19 | ||
20 | # Tool: `gen` | 20 | ## Tool: `gen` |
21 | 21 | ||
22 | This tool reads a "grammar" from [grammar.ron](../grammar.ron) and | 22 | This tool reads a "grammar" from [grammar.ron](../grammar.ron) and |
23 | generates the `syntax_kinds.rs` file. You should run this tool if you | 23 | generates the `syntax_kinds.rs` file. You should run this tool if you |
24 | add new keywords or syntax elements. | 24 | add new keywords or syntax elements. |
25 | 25 | ||
26 | 26 | ||
27 | # Tool: 'parse' | 27 | ## Tool: `parse` |
28 | 28 | ||
29 | This tool reads rust source code from the standard input, parses it, | 29 | This tool reads rust source code from the standard input, parses it, |
30 | and prints the result to stdout. | 30 | and prints the result to stdout. |
31 | |||
32 | |||
33 | ## Tool: `collect-tests` | ||
34 | |||
35 | This tools collect inline tests from comments in libsyntax2 source code | ||
36 | and places them into `tests/data/inline` directory. | ||