mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 00:24:52 +00:00
coverage: Branch coverage test for let-else
This commit is contained in:
parent
b3e117044c
commit
4f7a47798e
18
tests/coverage/branch/let-else.cov-map
Normal file
18
tests/coverage/branch/let-else.cov-map
Normal file
|
@ -0,0 +1,18 @@
|
|||
Function name: let_else::let_else
|
||||
Raw bytes (38): 0x[01, 01, 02, 05, 09, 09, 02, 06, 01, 0c, 01, 01, 10, 02, 03, 0e, 00, 0f, 05, 00, 13, 00, 18, 09, 01, 09, 01, 0f, 02, 04, 05, 00, 0b, 07, 01, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 2
|
||||
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||
Number of file 0 mappings: 6
|
||||
- Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16)
|
||||
- Code(Expression(0, Sub)) at (prev + 3, 14) to (start + 0, 15)
|
||||
= (c1 - c2)
|
||||
- Code(Counter(1)) at (prev + 0, 19) to (start + 0, 24)
|
||||
- Code(Counter(2)) at (prev + 1, 9) to (start + 1, 15)
|
||||
- Code(Expression(0, Sub)) at (prev + 4, 5) to (start + 0, 11)
|
||||
= (c1 - c2)
|
||||
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||
= (c2 + (c1 - c2))
|
||||
|
37
tests/coverage/branch/let-else.coverage
Normal file
37
tests/coverage/branch/let-else.coverage
Normal file
|
@ -0,0 +1,37 @@
|
|||
LL| |#![feature(coverage_attribute)]
|
||||
LL| |//@ edition: 2021
|
||||
LL| |//@ compile-flags: -Zcoverage-options=branch
|
||||
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||
LL| |
|
||||
LL| |macro_rules! no_merge {
|
||||
LL| | () => {
|
||||
LL| | for _ in 0..1 {}
|
||||
LL| | };
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| 3|fn let_else(value: Option<&str>) {
|
||||
LL| 3| no_merge!();
|
||||
LL| |
|
||||
LL| 3| let Some(x) = value else {
|
||||
^2
|
||||
LL| 1| say("none");
|
||||
LL| 1| return;
|
||||
LL| | };
|
||||
LL| |
|
||||
LL| 2| say(x);
|
||||
LL| 3|}
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |fn say(message: &str) {
|
||||
LL| | core::hint::black_box(message);
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |fn main() {
|
||||
LL| | let_else(Some("x"));
|
||||
LL| | let_else(Some("x"));
|
||||
LL| | let_else(None);
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |// FIXME(#124118) Actually instrument let-else for branch coverage.
|
||||
|
35
tests/coverage/branch/let-else.rs
Normal file
35
tests/coverage/branch/let-else.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
#![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 let_else(value: Option<&str>) {
|
||||
no_merge!();
|
||||
|
||||
let Some(x) = value else {
|
||||
say("none");
|
||||
return;
|
||||
};
|
||||
|
||||
say(x);
|
||||
}
|
||||
|
||||
#[coverage(off)]
|
||||
fn say(message: &str) {
|
||||
core::hint::black_box(message);
|
||||
}
|
||||
|
||||
#[coverage(off)]
|
||||
fn main() {
|
||||
let_else(Some("x"));
|
||||
let_else(Some("x"));
|
||||
let_else(None);
|
||||
}
|
||||
|
||||
// FIXME(#124118) Actually instrument let-else for branch coverage.
|
Loading…
Reference in a new issue