diff options
author | Aleksey Kladov <[email protected]> | 2018-02-03 19:39:01 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-02-03 19:39:01 +0000 |
commit | 2fd3228525858f594361eba345ff31087f8a917a (patch) | |
tree | 280d0d71a4159a2877c6c608ce08465b17c580b7 /docs | |
parent | 9b3d806b0dbfcf76ff707aa86daba83454227720 (diff) |
Document inline tests infra
Diffstat (limited to 'docs')
-rw-r--r-- | docs/TESTS.md | 16 |
1 files changed, 15 insertions, 1 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. |