1 LL| |// Enables `coverage(off)` on the entire crate
2 LL| |#![feature(coverage_attribute)]
5 LL| |fn do_not_add_coverage_1() {
6 LL| | println!("called but not covered");
9 LL| |fn do_not_add_coverage_2() {
10 LL| | #![coverage(off)]
11 LL| | println!("called but not covered");
15 LL| |#[allow(dead_code)]
16 LL| |fn do_not_add_coverage_not_called() {
17 LL| | println!("not called and not covered");
20 LL| 1|fn add_coverage_1() {
21 LL| 1| println!("called and covered");
24 LL| 1|fn add_coverage_2() {
25 LL| 1| println!("called and covered");
28 LL| |#[allow(dead_code)]
29 LL| 0|fn add_coverage_not_called() {
30 LL| 0| println!("not called but covered");
33 LL| |// FIXME: These test-cases illustrate confusing results of nested functions.
34 LL| |// See https://github.com/rust-lang/rust/issues/93319
36 LL| | #[coverage(off)]
37 LL| | pub fn outer_not_covered(is_true: bool) {
38 LL| 1| fn inner(is_true: bool) {
40 LL| 1| println!("called and covered");
42 LL| 0| println!("absolutely not covered");
45 LL| | println!("called but not covered");
49 LL| 1| pub fn outer(is_true: bool) {
50 LL| 1| println!("called and covered");
51 LL| 1| inner_not_covered(is_true);
53 LL| 1| #[coverage(off)]
54 LL| 1| fn inner_not_covered(is_true: bool) {
56 LL| 1| println!("called but not covered");
58 LL| 1| println!("absolutely not covered");
63 LL| 1| pub fn outer_both_covered(is_true: bool) {
64 LL| 1| println!("called and covered");
65 LL| 1| inner(is_true);
67 LL| 1| fn inner(is_true: bool) {
69 LL| 1| println!("called and covered");
71 LL| 0| println!("absolutely not covered");
78 LL| 1| let is_true = std::env::args().len() == 1;
80 LL| 1| do_not_add_coverage_1();
81 LL| 1| do_not_add_coverage_2();
82 LL| 1| add_coverage_1();
83 LL| 1| add_coverage_2();
85 LL| 1| nested_fns::outer_not_covered(is_true);
86 LL| 1| nested_fns::outer(is_true);
87 LL| 1| nested_fns::outer_both_covered(is_true);