]> git.lizzy.rs Git - rust.git/blob - src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.doctest.txt
Auto merge of #77853 - ijackson:slice-strip-stab, r=Amanieu
[rust.git] / src / test / run-make-fulldeps / coverage-reports / expected_show_coverage.doctest.txt
1 ../coverage/doctest.rs:
2     1|       |//! This test ensures that code from doctests is properly re-mapped.
3     2|       |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
4     3|       |//!
5     4|       |//! Just some random code:
6     5|      1|//! ```
7     6|      1|//! if true {
8     7|       |//!     // this is executed!
9     8|      1|//!     assert_eq!(1, 1);
10     9|       |//! } else {
11    10|       |//!     // this is not!
12    11|       |//!     assert_eq!(1, 2);
13    12|       |//! }
14    13|      1|//! ```
15    14|       |//!
16    15|       |//! doctest testing external code:
17    16|       |//! ```
18    17|      1|//! extern crate doctest_crate;
19    18|      1|//! doctest_crate::fn_run_in_doctests(1);
20    19|      1|//! ```
21    20|       |//!
22    21|       |//! doctest returning a result:
23    22|      1|//! ```
24    23|      1|//! #[derive(Debug)]
25    24|      1|//! struct SomeError;
26    25|      1|//! let mut res = Err(SomeError);
27    26|      1|//! if res.is_ok() {
28    27|      0|//!   res?;
29    28|      1|//! } else {
30    29|      1|//!   res = Ok(0);
31    30|      1|//! }
32    31|       |//! // need to be explicit because rustdoc cant infer the return type
33    32|      1|//! Ok::<(), SomeError>(())
34    33|      1|//! ```
35    34|       |//!
36    35|       |//! doctest with custom main:
37    36|       |//! ```
38    37|       |//! #[derive(Debug)]
39    38|       |//! struct SomeError;
40    39|       |//!
41    40|       |//! extern crate doctest_crate;
42    41|       |//!
43    42|      1|//! fn doctest_main() -> Result<(), SomeError> {
44    43|      1|//!     doctest_crate::fn_run_in_doctests(2);
45    44|      1|//!     Ok(())
46    45|      1|//! }
47    46|       |//!
48    47|       |//! // this `main` is not shown as covered, as it clashes with all the other
49    48|       |//! // `main` functions that were automatically generated for doctests
50    49|       |//! fn main() -> Result<(), SomeError> {
51    50|       |//!     doctest_main()
52    51|       |//! }
53    52|       |//! ```
54    53|       |
55    54|       |/// doctest attached to fn testing external code:
56    55|       |/// ```
57    56|      1|/// extern crate doctest_crate;
58    57|      1|/// doctest_crate::fn_run_in_doctests(3);
59    58|      1|/// ```
60    59|       |///
61    60|      1|fn main() {
62    61|      1|    if true {
63    62|      1|        assert_eq!(1, 1);
64    63|       |    } else {
65    64|       |        assert_eq!(1, 2);
66    65|       |    }
67    66|      1|}
68
69 ../coverage/lib/doctest_crate.rs:
70     1|       |/// A function run only from within doctests
71     2|      3|pub fn fn_run_in_doctests(conditional: usize) {
72     3|      3|    match conditional {
73     4|      1|        1 => assert_eq!(1, 1), // this is run,
74     5|      1|        2 => assert_eq!(1, 1), // this,
75     6|      1|        3 => assert_eq!(1, 1), // and this too
76     7|      0|        _ => assert_eq!(1, 2), // however this is not
77     8|       |    }
78     9|      3|}
79