Skip to content

Commit e318b92

Browse files
committed
coverage: Add a dedicated test for coverage of if !
1 parent 9fad685 commit e318b92

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

tests/coverage/if_not.cov-map

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Function name: if_not::if_not
2+
Raw bytes (86): 0x[01, 01, 10, 01, 05, 05, 02, 3f, 09, 05, 02, 09, 3a, 3f, 09, 05, 02, 37, 0d, 09, 3a, 3f, 09, 05, 02, 0d, 32, 37, 0d, 09, 3a, 3f, 09, 05, 02, 0a, 01, 04, 01, 03, 0d, 02, 04, 05, 02, 06, 05, 02, 06, 00, 07, 3f, 04, 09, 00, 0d, 3a, 01, 05, 02, 06, 09, 02, 06, 00, 07, 37, 04, 09, 00, 0d, 32, 01, 05, 02, 06, 0d, 02, 0c, 02, 06, 2f, 03, 01, 00, 02]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 16
6+
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
7+
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
8+
- expression 2 operands: lhs = Expression(15, Add), rhs = Counter(2)
9+
- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub)
10+
- expression 4 operands: lhs = Counter(2), rhs = Expression(14, Sub)
11+
- expression 5 operands: lhs = Expression(15, Add), rhs = Counter(2)
12+
- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub)
13+
- expression 7 operands: lhs = Expression(13, Add), rhs = Counter(3)
14+
- expression 8 operands: lhs = Counter(2), rhs = Expression(14, Sub)
15+
- expression 9 operands: lhs = Expression(15, Add), rhs = Counter(2)
16+
- expression 10 operands: lhs = Counter(1), rhs = Expression(0, Sub)
17+
- expression 11 operands: lhs = Counter(3), rhs = Expression(12, Sub)
18+
- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(3)
19+
- expression 13 operands: lhs = Counter(2), rhs = Expression(14, Sub)
20+
- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(2)
21+
- expression 15 operands: lhs = Counter(1), rhs = Expression(0, Sub)
22+
Number of file 0 mappings: 10
23+
- Code(Counter(0)) at (prev + 4, 1) to (start + 3, 13)
24+
- Code(Expression(0, Sub)) at (prev + 4, 5) to (start + 2, 6)
25+
= (c0 - c1)
26+
- Code(Counter(1)) at (prev + 2, 6) to (start + 0, 7)
27+
- Code(Expression(15, Add)) at (prev + 4, 9) to (start + 0, 13)
28+
= (c1 + (c0 - c1))
29+
- Code(Expression(14, Sub)) at (prev + 1, 5) to (start + 2, 6)
30+
= ((c1 + (c0 - c1)) - c2)
31+
- Code(Counter(2)) at (prev + 2, 6) to (start + 0, 7)
32+
- Code(Expression(13, Add)) at (prev + 4, 9) to (start + 0, 13)
33+
= (c2 + ((c1 + (c0 - c1)) - c2))
34+
- Code(Expression(12, Sub)) at (prev + 1, 5) to (start + 2, 6)
35+
= ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)
36+
- Code(Counter(3)) at (prev + 2, 12) to (start + 2, 6)
37+
- Code(Expression(11, Add)) at (prev + 3, 1) to (start + 0, 2)
38+
= (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3))
39+

tests/coverage/if_not.coverage

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
LL| |#![feature(coverage_attribute)]
2+
LL| |// edition: 2021
3+
LL| |
4+
LL| 12|fn if_not(cond: bool) {
5+
LL| 12| if
6+
LL| 12| !
7+
LL| 12| cond
8+
LL| 4| {
9+
LL| 4| println!("cond was false");
10+
LL| 8| }
11+
LL| |
12+
LL| | if
13+
LL| | !
14+
LL| 12| cond
15+
LL| 4| {
16+
LL| 4| println!("cond was false");
17+
LL| 8| }
18+
LL| |
19+
LL| | if
20+
LL| | !
21+
LL| 12| cond
22+
LL| 4| {
23+
LL| 4| println!("cond was false");
24+
LL| 8| } else {
25+
LL| 8| println!("cond was true");
26+
LL| 8| }
27+
LL| 12|}
28+
LL| |
29+
LL| |#[coverage(off)]
30+
LL| |fn main() {
31+
LL| | for _ in 0..8 {
32+
LL| | if_not(std::hint::black_box(true));
33+
LL| | }
34+
LL| | for _ in 0..4 {
35+
LL| | if_not(std::hint::black_box(false));
36+
LL| | }
37+
LL| |}
38+

tests/coverage/if_not.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#![feature(coverage_attribute)]
2+
// edition: 2021
3+
4+
fn if_not(cond: bool) {
5+
if
6+
!
7+
cond
8+
{
9+
println!("cond was false");
10+
}
11+
12+
if
13+
!
14+
cond
15+
{
16+
println!("cond was false");
17+
}
18+
19+
if
20+
!
21+
cond
22+
{
23+
println!("cond was false");
24+
} else {
25+
println!("cond was true");
26+
}
27+
}
28+
29+
#[coverage(off)]
30+
fn main() {
31+
for _ in 0..8 {
32+
if_not(std::hint::black_box(true));
33+
}
34+
for _ in 0..4 {
35+
if_not(std::hint::black_box(false));
36+
}
37+
}

0 commit comments

Comments
 (0)