diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-04-17 11:41:40 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-04-17 11:41:40 +1000 |
| commit | 40cfc2de77a605a2b373c0767037065d304d556a (patch) | |
| tree | 3888ac3aa319b1e93e312b2bd8ab2d575b237cfb /tests/coverage/branch/guard.rs | |
| parent | 3fba2782310b2754259a3c329220a5b1e6cf9a5c (diff) | |
| download | rust-40cfc2de77a605a2b373c0767037065d304d556a.tar.gz rust-40cfc2de77a605a2b373c0767037065d304d556a.zip | |
coverage: Move branch coverage tests into a subdirectory
Diffstat (limited to 'tests/coverage/branch/guard.rs')
| -rw-r--r-- | tests/coverage/branch/guard.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/coverage/branch/guard.rs b/tests/coverage/branch/guard.rs new file mode 100644 index 00000000000..fa049e6206d --- /dev/null +++ b/tests/coverage/branch/guard.rs @@ -0,0 +1,37 @@ +#![feature(coverage_attribute)] +//@ edition: 2021 +//@ compile-flags: -Zcoverage-options=branch +//@ llvm-cov-flags: --show-branches=count + +macro_rules! no_merge { + () => { + for _ in 0..1 {} + }; +} + +fn branch_match_guard(x: Option<u32>) { + no_merge!(); + + match x { + Some(0) => { + println!("zero"); + } + Some(x) if x % 2 == 0 => { + println!("is nonzero and even"); + } + Some(x) if x % 3 == 0 => { + println!("is nonzero and odd, but divisible by 3"); + } + _ => { + println!("something else"); + } + } +} + +#[coverage(off)] +fn main() { + branch_match_guard(Some(0)); + branch_match_guard(Some(2)); + branch_match_guard(Some(6)); + branch_match_guard(Some(3)); +} |
