-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added match or-pattern branch coverage test
- Loading branch information
1 parent
f758844
commit 3af90ae
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Function name: match_or_pattern_simple::foo | ||
Raw bytes (50): 0x[01, 01, 06, 01, 07, 05, 09, 09, 05, 05, 02, 09, 17, 05, 02, 06, 01, 08, 01, 01, 17, 20, 02, 0b, 02, 09, 00, 0a, 20, 05, 09, 00, 0d, 00, 0e, 17, 00, 12, 02, 0a, 09, 03, 0e, 02, 0a, 13, 04, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 6 | ||
- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) | ||
- expression 1 operands: lhs = Counter(1), rhs = Counter(2) | ||
- expression 2 operands: lhs = Counter(2), rhs = Counter(1) | ||
- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Add) | ||
- expression 5 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
Number of file 0 mappings: 6 | ||
- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 23) | ||
- Branch { true: Expression(0, Sub), false: Expression(2, Add) } at (prev + 2, 9) to (start + 0, 10) | ||
true = (c0 - (c1 + c2)) | ||
false = (c2 + c1) | ||
- Branch { true: Counter(1), false: Counter(2) } at (prev + 0, 13) to (start + 0, 14) | ||
true = c1 | ||
false = c2 | ||
- Code(Expression(5, Add)) at (prev + 0, 18) to (start + 2, 10) | ||
= (c1 + (c0 - (c1 + c2))) | ||
- Code(Counter(2)) at (prev + 3, 14) to (start + 2, 10) | ||
- Code(Expression(4, Add)) at (prev + 4, 1) to (start + 0, 2) | ||
= (c2 + (c1 + (c0 - (c1 + c2)))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
LL| |#![feature(coverage_attribute)] | ||
LL| |//@ edition: 2021 | ||
LL| |//@ compile-flags: -Zcoverage-options=branch | ||
LL| |//@ llvm-cov-flags: --show-branches=count | ||
LL| | | ||
LL| |use core::hint::black_box; | ||
LL| | | ||
LL| 3|fn foo(a: i32) { | ||
LL| 3| match black_box(a) { | ||
LL| 1| 1 | 2 => { | ||
------------------ | ||
| Branch (LL:9): [True: 1, False: 2] | ||
| Branch (LL:13): [True: 0, False: 2] | ||
------------------ | ||
LL| 1| consume(1); | ||
LL| 1| } | ||
LL| 2| _ => { | ||
LL| 2| consume(2); | ||
LL| 2| } | ||
LL| | } | ||
LL| 3|} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn consume<T>(x: T) { | ||
LL| | core::hint::black_box(x); | ||
LL| |} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn main() { | ||
LL| | foo(1); | ||
LL| | foo(3); | ||
LL| | foo(4); | ||
LL| |} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![feature(coverage_attribute)] | ||
//@ edition: 2021 | ||
//@ compile-flags: -Zcoverage-options=branch | ||
//@ llvm-cov-flags: --show-branches=count | ||
|
||
use core::hint::black_box; | ||
|
||
fn foo(a: i32) { | ||
match black_box(a) { | ||
1 | 2 => { | ||
consume(1); | ||
} | ||
_ => { | ||
consume(2); | ||
} | ||
} | ||
} | ||
|
||
#[coverage(off)] | ||
fn consume<T>(x: T) { | ||
core::hint::black_box(x); | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
foo(1); | ||
foo(3); | ||
foo(4); | ||
} |