mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
Rollup merge of #124053 - Zalathar:lazy-boolean, r=Mark-Simulacrum
coverage: Branch coverage tests for lazy boolean operators The current branch coverage implementation already supports the `&&` and `||` operators (even outside of an `if` condition), as a natural consequence of how they are desugared/lowered, but we didn't have any specific tests for them. This PR adds some appropriate tests. I've also moved the existing branch coverage tests into a `coverage/branch` subdirectory, so that they don't become unwieldy as I add more branch coverage tests. ``@rustbot`` label +A-code-coverage
This commit is contained in:
commit
f13cd0c8d0
@ -1,4 +1,4 @@
|
||||
Function name: branch_generics::print_size::<()>
|
||||
Function name: generics::print_size::<()>
|
||||
Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -16,7 +16,7 @@ Number of file 0 mappings: 5
|
||||
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||
= (c1 + (c0 - c1))
|
||||
|
||||
Function name: branch_generics::print_size::<u32>
|
||||
Function name: generics::print_size::<u32>
|
||||
Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -34,7 +34,7 @@ Number of file 0 mappings: 5
|
||||
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||
= (c1 + (c0 - c1))
|
||||
|
||||
Function name: branch_generics::print_size::<u64>
|
||||
Function name: generics::print_size::<u64>
|
||||
Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
@ -16,7 +16,7 @@
|
||||
LL| 2| }
|
||||
LL| 3|}
|
||||
------------------
|
||||
| branch_generics::print_size::<()>:
|
||||
| generics::print_size::<()>:
|
||||
| LL| 1|fn print_size<T>() {
|
||||
| LL| 1| if std::mem::size_of::<T>() > 4 {
|
||||
| ------------------
|
||||
@ -28,7 +28,7 @@
|
||||
| LL| 1| }
|
||||
| LL| 1|}
|
||||
------------------
|
||||
| branch_generics::print_size::<u32>:
|
||||
| generics::print_size::<u32>:
|
||||
| LL| 1|fn print_size<T>() {
|
||||
| LL| 1| if std::mem::size_of::<T>() > 4 {
|
||||
| ------------------
|
||||
@ -40,7 +40,7 @@
|
||||
| LL| 1| }
|
||||
| LL| 1|}
|
||||
------------------
|
||||
| branch_generics::print_size::<u64>:
|
||||
| generics::print_size::<u64>:
|
||||
| LL| 1|fn print_size<T>() {
|
||||
| LL| 1| if std::mem::size_of::<T>() > 4 {
|
||||
| ------------------
|
@ -1,4 +1,4 @@
|
||||
Function name: branch_guard::branch_match_guard
|
||||
Function name: guard::branch_match_guard
|
||||
Raw bytes (85): 0x[01, 01, 06, 19, 0d, 05, 09, 0f, 15, 13, 11, 17, 0d, 05, 09, 0d, 01, 0c, 01, 01, 10, 1d, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 20, 0d, 02, 00, 14, 00, 1e, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 1d, 00, 14, 00, 19, 20, 11, 09, 00, 14, 00, 1e, 11, 00, 1d, 02, 0a, 17, 03, 0e, 02, 0a, 0b, 04, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
@ -1,4 +1,4 @@
|
||||
Function name: branch_if::branch_and
|
||||
Function name: if::branch_and
|
||||
Raw bytes (56): 0x[01, 01, 04, 05, 09, 0d, 02, 11, 0f, 0d, 02, 08, 01, 2b, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 00, 0d, 00, 0e, 20, 11, 0d, 00, 0d, 00, 0e, 11, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -23,7 +23,7 @@ Number of file 0 mappings: 8
|
||||
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||
= (c4 + (c3 + (c1 - c2)))
|
||||
|
||||
Function name: branch_if::branch_not
|
||||
Function name: if::branch_not
|
||||
Raw bytes (224): 0x[01, 01, 29, 05, 09, 09, 02, a3, 01, 0d, 09, 02, a3, 01, 0d, 09, 02, 0d, 9e, 01, a3, 01, 0d, 09, 02, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 15, 8e, 01, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 12, 01, 0c, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 01, 09, 00, 11, 02, 01, 06, 00, 07, a3, 01, 01, 08, 00, 0a, 20, 9e, 01, 0d, 00, 08, 00, 0a, 9e, 01, 00, 0b, 02, 06, 0d, 02, 06, 00, 07, 9b, 01, 01, 08, 00, 0b, 20, 11, 96, 01, 00, 08, 00, 0b, 11, 00, 0c, 02, 06, 96, 01, 02, 06, 00, 07, 93, 01, 01, 08, 00, 0c, 20, 8e, 01, 15, 00, 08, 00, 0c, 8e, 01, 00, 0d, 02, 06, 15, 02, 06, 00, 07, 8b, 01, 01, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -105,7 +105,7 @@ Number of file 0 mappings: 18
|
||||
- Code(Expression(34, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||
= (c5 + ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5))
|
||||
|
||||
Function name: branch_if::branch_not_as
|
||||
Function name: if::branch_not_as
|
||||
Raw bytes (124): 0x[01, 01, 16, 05, 09, 09, 02, 57, 0d, 09, 02, 57, 0d, 09, 02, 0d, 52, 57, 0d, 09, 02, 4f, 11, 0d, 52, 57, 0d, 09, 02, 4f, 11, 0d, 52, 57, 0d, 09, 02, 11, 4a, 4f, 11, 0d, 52, 57, 0d, 09, 02, 0e, 01, 1d, 01, 01, 10, 05, 03, 08, 00, 14, 20, 02, 09, 00, 08, 00, 14, 02, 00, 15, 02, 06, 09, 02, 06, 00, 07, 57, 01, 08, 00, 15, 20, 0d, 52, 00, 08, 00, 15, 0d, 00, 16, 02, 06, 52, 02, 06, 00, 07, 4f, 01, 08, 00, 16, 20, 4a, 11, 00, 08, 00, 16, 4a, 00, 17, 02, 06, 11, 02, 06, 00, 07, 47, 01, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -160,7 +160,7 @@ Number of file 0 mappings: 14
|
||||
- Code(Expression(17, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||
= (c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4))
|
||||
|
||||
Function name: branch_if::branch_or
|
||||
Function name: if::branch_or
|
||||
Raw bytes (56): 0x[01, 01, 04, 05, 09, 09, 0d, 0f, 11, 09, 0d, 08, 01, 35, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 20, 0d, 11, 00, 0d, 00, 0e, 0f, 00, 0f, 02, 06, 11, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
177
tests/coverage/branch/lazy-boolean.cov-map
Normal file
177
tests/coverage/branch/lazy-boolean.cov-map
Normal file
@ -0,0 +1,177 @@
|
||||
Function name: lazy_boolean::branch_and
|
||||
Raw bytes (42): 0x[01, 01, 03, 09, 0a, 05, 09, 05, 09, 06, 01, 13, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0d, 00, 0e, 20, 09, 0a, 00, 0d, 00, 0e, 09, 00, 12, 00, 13, 03, 01, 05, 01, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 3
|
||||
- expression 0 operands: lhs = Counter(2), rhs = Expression(2, Sub)
|
||||
- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 2 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
Number of file 0 mappings: 6
|
||||
- Code(Counter(0)) at (prev + 19, 1) to (start + 1, 16)
|
||||
- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10)
|
||||
= (c2 + (c1 - c2))
|
||||
- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14)
|
||||
- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 13) to (start + 0, 14)
|
||||
true = c2
|
||||
false = (c1 - c2)
|
||||
- Code(Counter(2)) at (prev + 0, 18) to (start + 0, 19)
|
||||
- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2)
|
||||
= (c2 + (c1 - c2))
|
||||
|
||||
Function name: lazy_boolean::branch_or
|
||||
Raw bytes (44): 0x[01, 01, 04, 09, 0e, 05, 09, 05, 09, 05, 09, 06, 01, 1b, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0d, 00, 0e, 20, 09, 0e, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 03, 01, 05, 01, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 4
|
||||
- expression 0 operands: lhs = Counter(2), rhs = Expression(3, Sub)
|
||||
- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 2 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 3 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
Number of file 0 mappings: 6
|
||||
- Code(Counter(0)) at (prev + 27, 1) to (start + 1, 16)
|
||||
- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10)
|
||||
= (c2 + (c1 - c2))
|
||||
- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14)
|
||||
- Branch { true: Counter(2), false: Expression(3, Sub) } at (prev + 0, 13) to (start + 0, 14)
|
||||
true = c2
|
||||
false = (c1 - c2)
|
||||
- Code(Expression(3, Sub)) at (prev + 0, 18) to (start + 0, 19)
|
||||
= (c1 - c2)
|
||||
- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2)
|
||||
= (c2 + (c1 - c2))
|
||||
|
||||
Function name: lazy_boolean::chain
|
||||
Raw bytes (149): 0x[01, 01, 13, 11, 07, 0b, 16, 15, 1a, 09, 0d, 05, 09, 05, 09, 09, 0d, 47, 25, 4b, 21, 19, 1d, 03, 19, 03, 19, 3e, 1d, 03, 19, 3e, 1d, 03, 19, 47, 25, 4b, 21, 19, 1d, 13, 01, 24, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0d, 00, 12, 20, 09, 16, 00, 0d, 00, 12, 09, 00, 16, 00, 1b, 20, 0d, 1a, 00, 16, 00, 1b, 0d, 00, 1f, 00, 24, 20, 11, 15, 00, 1f, 00, 24, 11, 00, 28, 00, 2d, 03, 01, 05, 00, 11, 43, 03, 09, 00, 0a, 03, 00, 0d, 00, 12, 20, 19, 3e, 00, 0d, 00, 12, 3e, 00, 16, 00, 1b, 20, 1d, 3a, 00, 16, 00, 1b, 3a, 00, 1f, 00, 24, 20, 21, 25, 00, 1f, 00, 24, 25, 00, 28, 00, 2d, 43, 01, 05, 01, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 19
|
||||
- expression 0 operands: lhs = Counter(4), rhs = Expression(1, Add)
|
||||
- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(5, Sub)
|
||||
- expression 2 operands: lhs = Counter(5), rhs = Expression(6, Sub)
|
||||
- expression 3 operands: lhs = Counter(2), rhs = Counter(3)
|
||||
- expression 4 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 5 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 6 operands: lhs = Counter(2), rhs = Counter(3)
|
||||
- expression 7 operands: lhs = Expression(17, Add), rhs = Counter(9)
|
||||
- expression 8 operands: lhs = Expression(18, Add), rhs = Counter(8)
|
||||
- expression 9 operands: lhs = Counter(6), rhs = Counter(7)
|
||||
- expression 10 operands: lhs = Expression(0, Add), rhs = Counter(6)
|
||||
- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(6)
|
||||
- expression 12 operands: lhs = Expression(15, Sub), rhs = Counter(7)
|
||||
- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(6)
|
||||
- expression 14 operands: lhs = Expression(15, Sub), rhs = Counter(7)
|
||||
- expression 15 operands: lhs = Expression(0, Add), rhs = Counter(6)
|
||||
- expression 16 operands: lhs = Expression(17, Add), rhs = Counter(9)
|
||||
- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(8)
|
||||
- expression 18 operands: lhs = Counter(6), rhs = Counter(7)
|
||||
Number of file 0 mappings: 19
|
||||
- Code(Counter(0)) at (prev + 36, 1) to (start + 1, 16)
|
||||
- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10)
|
||||
= (c4 + ((c5 + (c2 - c3)) + (c1 - c2)))
|
||||
- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 18)
|
||||
- Branch { true: Counter(2), false: Expression(5, Sub) } at (prev + 0, 13) to (start + 0, 18)
|
||||
true = c2
|
||||
false = (c1 - c2)
|
||||
- Code(Counter(2)) at (prev + 0, 22) to (start + 0, 27)
|
||||
- Branch { true: Counter(3), false: Expression(6, Sub) } at (prev + 0, 22) to (start + 0, 27)
|
||||
true = c3
|
||||
false = (c2 - c3)
|
||||
- Code(Counter(3)) at (prev + 0, 31) to (start + 0, 36)
|
||||
- Branch { true: Counter(4), false: Counter(5) } at (prev + 0, 31) to (start + 0, 36)
|
||||
true = c4
|
||||
false = c5
|
||||
- Code(Counter(4)) at (prev + 0, 40) to (start + 0, 45)
|
||||
- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 17)
|
||||
= (c4 + ((c5 + (c2 - c3)) + (c1 - c2)))
|
||||
- Code(Expression(16, Add)) at (prev + 3, 9) to (start + 0, 10)
|
||||
= (((c6 + c7) + c8) + c9)
|
||||
- Code(Expression(0, Add)) at (prev + 0, 13) to (start + 0, 18)
|
||||
= (c4 + ((c5 + (c2 - c3)) + (c1 - c2)))
|
||||
- Branch { true: Counter(6), false: Expression(15, Sub) } at (prev + 0, 13) to (start + 0, 18)
|
||||
true = c6
|
||||
false = ((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6)
|
||||
- Code(Expression(15, Sub)) at (prev + 0, 22) to (start + 0, 27)
|
||||
= ((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6)
|
||||
- Branch { true: Counter(7), false: Expression(14, Sub) } at (prev + 0, 22) to (start + 0, 27)
|
||||
true = c7
|
||||
false = (((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6) - c7)
|
||||
- Code(Expression(14, Sub)) at (prev + 0, 31) to (start + 0, 36)
|
||||
= (((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6) - c7)
|
||||
- Branch { true: Counter(8), false: Counter(9) } at (prev + 0, 31) to (start + 0, 36)
|
||||
true = c8
|
||||
false = c9
|
||||
- Code(Counter(9)) at (prev + 0, 40) to (start + 0, 45)
|
||||
- Code(Expression(16, Add)) at (prev + 1, 5) to (start + 1, 2)
|
||||
= (((c6 + c7) + c8) + c9)
|
||||
|
||||
Function name: lazy_boolean::nested_mixed
|
||||
Raw bytes (159): 0x[01, 01, 18, 07, 22, 11, 36, 3b, 11, 09, 0d, 26, 0d, 05, 09, 05, 09, 05, 09, 26, 0d, 05, 09, 09, 0d, 3b, 11, 09, 0d, 3b, 11, 09, 0d, 19, 5f, 1d, 21, 03, 15, 15, 19, 52, 56, 15, 19, 03, 15, 19, 5f, 1d, 21, 13, 01, 31, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0e, 00, 13, 20, 09, 26, 00, 0e, 00, 13, 26, 00, 17, 00, 1d, 20, 0d, 22, 00, 17, 00, 1d, 3b, 00, 23, 00, 28, 20, 11, 36, 00, 23, 00, 28, 36, 00, 2c, 00, 33, 03, 01, 05, 00, 11, 5b, 03, 09, 00, 0a, 03, 00, 0e, 00, 13, 20, 15, 56, 00, 0e, 00, 13, 15, 00, 17, 00, 1c, 20, 19, 52, 00, 17, 00, 1c, 4f, 00, 22, 00, 28, 20, 1d, 21, 00, 22, 00, 28, 1d, 00, 2c, 00, 33, 5b, 01, 05, 01, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 24
|
||||
- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(8, Sub)
|
||||
- expression 1 operands: lhs = Counter(4), rhs = Expression(13, Sub)
|
||||
- expression 2 operands: lhs = Expression(14, Add), rhs = Counter(4)
|
||||
- expression 3 operands: lhs = Counter(2), rhs = Counter(3)
|
||||
- expression 4 operands: lhs = Expression(9, Sub), rhs = Counter(3)
|
||||
- expression 5 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 6 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 7 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 8 operands: lhs = Expression(9, Sub), rhs = Counter(3)
|
||||
- expression 9 operands: lhs = Counter(1), rhs = Counter(2)
|
||||
- expression 10 operands: lhs = Counter(2), rhs = Counter(3)
|
||||
- expression 11 operands: lhs = Expression(14, Add), rhs = Counter(4)
|
||||
- expression 12 operands: lhs = Counter(2), rhs = Counter(3)
|
||||
- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(4)
|
||||
- expression 14 operands: lhs = Counter(2), rhs = Counter(3)
|
||||
- expression 15 operands: lhs = Counter(6), rhs = Expression(23, Add)
|
||||
- expression 16 operands: lhs = Counter(7), rhs = Counter(8)
|
||||
- expression 17 operands: lhs = Expression(0, Add), rhs = Counter(5)
|
||||
- expression 18 operands: lhs = Counter(5), rhs = Counter(6)
|
||||
- expression 19 operands: lhs = Expression(20, Sub), rhs = Expression(21, Sub)
|
||||
- expression 20 operands: lhs = Counter(5), rhs = Counter(6)
|
||||
- expression 21 operands: lhs = Expression(0, Add), rhs = Counter(5)
|
||||
- expression 22 operands: lhs = Counter(6), rhs = Expression(23, Add)
|
||||
- expression 23 operands: lhs = Counter(7), rhs = Counter(8)
|
||||
Number of file 0 mappings: 19
|
||||
- Code(Counter(0)) at (prev + 49, 1) to (start + 1, 16)
|
||||
- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10)
|
||||
= ((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3))
|
||||
- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 19)
|
||||
- Branch { true: Counter(2), false: Expression(9, Sub) } at (prev + 0, 14) to (start + 0, 19)
|
||||
true = c2
|
||||
false = (c1 - c2)
|
||||
- Code(Expression(9, Sub)) at (prev + 0, 23) to (start + 0, 29)
|
||||
= (c1 - c2)
|
||||
- Branch { true: Counter(3), false: Expression(8, Sub) } at (prev + 0, 23) to (start + 0, 29)
|
||||
true = c3
|
||||
false = ((c1 - c2) - c3)
|
||||
- Code(Expression(14, Add)) at (prev + 0, 35) to (start + 0, 40)
|
||||
= (c2 + c3)
|
||||
- Branch { true: Counter(4), false: Expression(13, Sub) } at (prev + 0, 35) to (start + 0, 40)
|
||||
true = c4
|
||||
false = ((c2 + c3) - c4)
|
||||
- Code(Expression(13, Sub)) at (prev + 0, 44) to (start + 0, 51)
|
||||
= ((c2 + c3) - c4)
|
||||
- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 17)
|
||||
= ((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3))
|
||||
- Code(Expression(22, Add)) at (prev + 3, 9) to (start + 0, 10)
|
||||
= (c6 + (c7 + c8))
|
||||
- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 19)
|
||||
= ((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3))
|
||||
- Branch { true: Counter(5), false: Expression(21, Sub) } at (prev + 0, 14) to (start + 0, 19)
|
||||
true = c5
|
||||
false = (((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) - c5)
|
||||
- Code(Counter(5)) at (prev + 0, 23) to (start + 0, 28)
|
||||
- Branch { true: Counter(6), false: Expression(20, Sub) } at (prev + 0, 23) to (start + 0, 28)
|
||||
true = c6
|
||||
false = (c5 - c6)
|
||||
- Code(Expression(19, Add)) at (prev + 0, 34) to (start + 0, 40)
|
||||
= ((c5 - c6) + (((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) - c5))
|
||||
- Branch { true: Counter(7), false: Counter(8) } at (prev + 0, 34) to (start + 0, 40)
|
||||
true = c7
|
||||
false = c8
|
||||
- Code(Counter(7)) at (prev + 0, 44) to (start + 0, 51)
|
||||
- Code(Expression(22, Add)) at (prev + 1, 5) to (start + 1, 2)
|
||||
= (c6 + (c7 + c8))
|
||||
|
113
tests/coverage/branch/lazy-boolean.coverage
Normal file
113
tests/coverage/branch/lazy-boolean.coverage
Normal file
@ -0,0 +1,113 @@
|
||||
LL| |#![feature(coverage_attribute)]
|
||||
LL| |//@ edition: 2021
|
||||
LL| |//@ compile-flags: -Zcoverage-options=branch
|
||||
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||
LL| |
|
||||
LL| |// Tests for branch coverage of the lazy boolean operators `&&` and `||`,
|
||||
LL| |// as ordinary expressions that aren't part of an `if` condition or similar.
|
||||
LL| |
|
||||
LL| |use core::hint::black_box;
|
||||
LL| |
|
||||
LL| |// Helper macro to prevent start-of-function spans from being merged into
|
||||
LL| |// spans on the lines we care about.
|
||||
LL| |macro_rules! no_merge {
|
||||
LL| | () => {
|
||||
LL| | for _ in 0..1 {}
|
||||
LL| | };
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| 15|fn branch_and(a: bool, b: bool) {
|
||||
LL| 15| no_merge!();
|
||||
LL| |
|
||||
LL| | // |13 |18 (no branch)
|
||||
LL| 15| let c = a && b;
|
||||
^12
|
||||
------------------
|
||||
| Branch (LL:13): [True: 12, False: 3]
|
||||
------------------
|
||||
LL| 15| black_box(c);
|
||||
LL| 15|}
|
||||
LL| |
|
||||
LL| 15|fn branch_or(a: bool, b: bool) {
|
||||
LL| 15| no_merge!();
|
||||
LL| |
|
||||
LL| | // |13 |18 (no branch)
|
||||
LL| 15| let c = a || b;
|
||||
^3
|
||||
------------------
|
||||
| Branch (LL:13): [True: 12, False: 3]
|
||||
------------------
|
||||
LL| 15| black_box(c);
|
||||
LL| 15|}
|
||||
LL| |
|
||||
LL| |// Test for chaining one operator several times.
|
||||
LL| 16|fn chain(x: u32) {
|
||||
LL| 16| no_merge!();
|
||||
LL| |
|
||||
LL| | // |13 |22 |31 |40 (no branch)
|
||||
LL| 16| let c = x > 1 && x > 2 && x > 4 && x > 8;
|
||||
^14 ^13 ^11
|
||||
------------------
|
||||
| Branch (LL:13): [True: 14, False: 2]
|
||||
| Branch (LL:22): [True: 13, False: 1]
|
||||
| Branch (LL:31): [True: 11, False: 2]
|
||||
------------------
|
||||
LL| 16| black_box(c);
|
||||
LL| |
|
||||
LL| | // |13 |22 |31 |40 (no branch)
|
||||
LL| 16| let d = x < 1 || x < 2 || x < 4 || x < 8;
|
||||
^15 ^14 ^12
|
||||
------------------
|
||||
| Branch (LL:13): [True: 1, False: 15]
|
||||
| Branch (LL:22): [True: 1, False: 14]
|
||||
| Branch (LL:31): [True: 2, False: 12]
|
||||
------------------
|
||||
LL| 16| black_box(d);
|
||||
LL| 16|}
|
||||
LL| |
|
||||
LL| |// Test for nested combinations of different operators.
|
||||
LL| 16|fn nested_mixed(x: u32) {
|
||||
LL| 16| no_merge!();
|
||||
LL| |
|
||||
LL| | // |14 |23 |35 |44 (no branch)
|
||||
LL| 16| let c = (x < 4 || x >= 9) && (x < 2 || x >= 10);
|
||||
^12 ^11 ^9
|
||||
------------------
|
||||
| Branch (LL:14): [True: 4, False: 12]
|
||||
| Branch (LL:23): [True: 7, False: 5]
|
||||
| Branch (LL:35): [True: 2, False: 9]
|
||||
------------------
|
||||
LL| 16| black_box(c);
|
||||
LL| |
|
||||
LL| | // |14 |23 |34 |44 (no branch)
|
||||
LL| 16| let d = (x < 4 && x < 1) || (x >= 8 && x >= 10);
|
||||
^4 ^15 ^8
|
||||
------------------
|
||||
| Branch (LL:14): [True: 4, False: 12]
|
||||
| Branch (LL:23): [True: 1, False: 3]
|
||||
| Branch (LL:34): [True: 8, False: 7]
|
||||
------------------
|
||||
LL| 16| black_box(d);
|
||||
LL| 16|}
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |fn main() {
|
||||
LL| | // Use each set of arguments (2^n) times, so that each combination has a
|
||||
LL| | // unique sum, and we can use those sums to verify expected control flow.
|
||||
LL| | // 1x (false, false)
|
||||
LL| | // 2x (false, true)
|
||||
LL| | // 4x (true, false)
|
||||
LL| | // 8x (true, true)
|
||||
LL| | for a in [false, true, true, true, true] {
|
||||
LL| | for b in [false, true, true] {
|
||||
LL| | branch_and(a, b);
|
||||
LL| | branch_or(a, b);
|
||||
LL| | }
|
||||
LL| | }
|
||||
LL| |
|
||||
LL| | for x in 0..16 {
|
||||
LL| | chain(x);
|
||||
LL| | nested_mixed(x);
|
||||
LL| | }
|
||||
LL| |}
|
||||
|
80
tests/coverage/branch/lazy-boolean.rs
Normal file
80
tests/coverage/branch/lazy-boolean.rs
Normal file
@ -0,0 +1,80 @@
|
||||
#![feature(coverage_attribute)]
|
||||
//@ edition: 2021
|
||||
//@ compile-flags: -Zcoverage-options=branch
|
||||
//@ llvm-cov-flags: --show-branches=count
|
||||
|
||||
// Tests for branch coverage of the lazy boolean operators `&&` and `||`,
|
||||
// as ordinary expressions that aren't part of an `if` condition or similar.
|
||||
|
||||
use core::hint::black_box;
|
||||
|
||||
// Helper macro to prevent start-of-function spans from being merged into
|
||||
// spans on the lines we care about.
|
||||
macro_rules! no_merge {
|
||||
() => {
|
||||
for _ in 0..1 {}
|
||||
};
|
||||
}
|
||||
|
||||
fn branch_and(a: bool, b: bool) {
|
||||
no_merge!();
|
||||
|
||||
// |13 |18 (no branch)
|
||||
let c = a && b;
|
||||
black_box(c);
|
||||
}
|
||||
|
||||
fn branch_or(a: bool, b: bool) {
|
||||
no_merge!();
|
||||
|
||||
// |13 |18 (no branch)
|
||||
let c = a || b;
|
||||
black_box(c);
|
||||
}
|
||||
|
||||
// Test for chaining one operator several times.
|
||||
fn chain(x: u32) {
|
||||
no_merge!();
|
||||
|
||||
// |13 |22 |31 |40 (no branch)
|
||||
let c = x > 1 && x > 2 && x > 4 && x > 8;
|
||||
black_box(c);
|
||||
|
||||
// |13 |22 |31 |40 (no branch)
|
||||
let d = x < 1 || x < 2 || x < 4 || x < 8;
|
||||
black_box(d);
|
||||
}
|
||||
|
||||
// Test for nested combinations of different operators.
|
||||
fn nested_mixed(x: u32) {
|
||||
no_merge!();
|
||||
|
||||
// |14 |23 |35 |44 (no branch)
|
||||
let c = (x < 4 || x >= 9) && (x < 2 || x >= 10);
|
||||
black_box(c);
|
||||
|
||||
// |14 |23 |34 |44 (no branch)
|
||||
let d = (x < 4 && x < 1) || (x >= 8 && x >= 10);
|
||||
black_box(d);
|
||||
}
|
||||
|
||||
#[coverage(off)]
|
||||
fn main() {
|
||||
// Use each set of arguments (2^n) times, so that each combination has a
|
||||
// unique sum, and we can use those sums to verify expected control flow.
|
||||
// 1x (false, false)
|
||||
// 2x (false, true)
|
||||
// 4x (true, false)
|
||||
// 8x (true, true)
|
||||
for a in [false, true, true, true, true] {
|
||||
for b in [false, true, true] {
|
||||
branch_and(a, b);
|
||||
branch_or(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
for x in 0..16 {
|
||||
chain(x);
|
||||
nested_mixed(x);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
Function name: branch_while::while_cond
|
||||
Function name: while::while_cond
|
||||
Raw bytes (42): 0x[01, 01, 03, 05, 09, 03, 09, 03, 09, 06, 01, 0c, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 10, 20, 09, 0a, 00, 0b, 00, 10, 09, 00, 11, 02, 06, 0a, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -18,7 +18,7 @@ Number of file 0 mappings: 6
|
||||
- Code(Expression(2, Sub)) at (prev + 3, 1) to (start + 0, 2)
|
||||
= ((c1 + c2) - c2)
|
||||
|
||||
Function name: branch_while::while_cond_not
|
||||
Function name: while::while_cond_not
|
||||
Raw bytes (42): 0x[01, 01, 03, 05, 09, 03, 09, 03, 09, 06, 01, 15, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 14, 20, 09, 0a, 00, 0b, 00, 14, 09, 00, 15, 02, 06, 0a, 03, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -38,7 +38,7 @@ Number of file 0 mappings: 6
|
||||
- Code(Expression(2, Sub)) at (prev + 3, 1) to (start + 0, 2)
|
||||
= ((c1 + c2) - c2)
|
||||
|
||||
Function name: branch_while::while_op_and
|
||||
Function name: while::while_op_and
|
||||
Raw bytes (56): 0x[01, 01, 04, 05, 09, 03, 0d, 03, 0d, 11, 0d, 08, 01, 1e, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 0a, 0d, 00, 0b, 00, 10, 0a, 00, 14, 00, 19, 20, 09, 11, 00, 14, 00, 19, 09, 00, 1a, 03, 06, 0f, 04, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
@ -64,7 +64,7 @@ Number of file 0 mappings: 8
|
||||
- Code(Expression(3, Add)) at (prev + 4, 1) to (start + 0, 2)
|
||||
= (c4 + c3)
|
||||
|
||||
Function name: branch_while::while_op_or
|
||||
Function name: while::while_op_or
|
||||
Raw bytes (66): 0x[01, 01, 09, 05, 1b, 09, 0d, 03, 09, 03, 09, 22, 0d, 03, 09, 09, 0d, 22, 0d, 03, 09, 08, 01, 29, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 09, 22, 00, 0b, 00, 10, 22, 00, 14, 00, 19, 20, 0d, 1e, 00, 14, 00, 19, 1b, 00, 1a, 03, 06, 1e, 04, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
Loading…
Reference in New Issue
Block a user