Skip to content

Commit

Permalink
coverage: Tweak individual tests to be unaffected by rustfmt
Browse files Browse the repository at this point in the history
Some of these tests use non-standard formatting that we can simulate by
strategically adding `//` line comments.

One contains `where` clauses that would be split across multiple lines, which
we can keep on one line by moving the bounds to the generic type instead.
  • Loading branch information
Zalathar committed Jan 16, 2024
1 parent f149442 commit 1f9353a
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 22 deletions.
4 changes: 2 additions & 2 deletions tests/coverage/conditions.cov-map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Function name: conditions::main
Raw bytes (784): 0x[01, 01, 8e, 01, 09, 33, 37, 41, 3b, 3d, 35, 39, 05, 00, b7, 04, 09, 05, 00, 0d, 35, 26, 39, 0d, 35, 3b, 3d, 35, 39, 37, 41, 3b, 3d, 35, 39, b2, 04, 0d, b7, 04, 09, 05, 00, 45, 00, 83, 01, 49, 45, 00, 7e, 31, 83, 01, 49, 45, 00, 7a, 4d, 7e, 31, 83, 01, 49, 45, 00, 76, 51, 7a, 4d, 7e, 31, 83, 01, 49, 45, 00, a7, 01, 55, 4d, 51, a3, 01, 59, a7, 01, 55, 4d, 51, 49, 9f, 01, a3, 01, 59, a7, 01, 55, 4d, 51, 61, 00, e3, 01, 65, 61, 00, de, 01, 2d, e3, 01, 65, 61, 00, da, 01, 69, de, 01, 2d, e3, 01, 65, 61, 00, d6, 01, 6d, da, 01, 69, de, 01, 2d, e3, 01, 65, 61, 00, 8b, 02, 71, 69, 6d, 87, 02, 75, 8b, 02, 71, 69, 6d, ff, 01, 00, 65, 83, 02, 87, 02, 75, 8b, 02, 71, 69, 6d, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 79, 00, d7, 02, 7d, 79, 00, d2, 02, 29, d7, 02, 7d, 79, 00, ce, 02, 81, 01, d2, 02, 29, d7, 02, 7d, 79, 00, ca, 02, 85, 01, ce, 02, 81, 01, d2, 02, 29, d7, 02, 7d, 79, 00, f3, 03, 89, 01, 81, 01, 85, 01, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 11, 93, 04, 97, 04, 21, 9b, 04, 1d, 15, 19, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, de, 03, 15, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, da, 03, 19, de, 03, 15, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 9b, 04, 1d, 15, 19, 97, 04, 21, 9b, 04, 1d, 15, 19, 8f, 04, 9f, 04, 11, 93, 04, 97, 04, 21, 9b, 04, 1d, 15, 19, a3, 04, ae, 04, a7, 04, 31, ab, 04, 2d, 25, 29, b2, 04, 0d, b7, 04, 09, 05, 00, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 06, 00, 07, 03, 03, 09, 00, 0a, b7, 04, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, b2, 04, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 26, 00, 1d, 00, 2a, 22, 00, 2e, 00, 3c, 37, 00, 3d, 02, 0a, 41, 02, 0a, 00, 0b, 33, 01, 09, 01, 12, ae, 04, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 83, 01, 02, 08, 00, 15, 49, 00, 16, 02, 06, 7e, 02, 0f, 00, 1c, 7a, 01, 0c, 00, 19, 76, 00, 1d, 00, 2a, 72, 00, 2e, 00, 3c, a3, 01, 00, 3d, 02, 0a, 59, 02, 0a, 00, 0b, 9f, 01, 01, 09, 00, 17, 31, 02, 09, 00, 0f, 9b, 01, 03, 08, 00, 0c, 5d, 01, 0d, 01, 10, 61, 01, 11, 02, 0a, 00, 02, 0a, 00, 0b, e3, 01, 02, 0c, 00, 19, 65, 00, 1a, 02, 0a, de, 01, 03, 11, 00, 1e, da, 01, 01, 10, 00, 1d, d6, 01, 00, 21, 00, 2e, d2, 01, 00, 32, 00, 40, 87, 02, 00, 41, 02, 0e, 75, 02, 0e, 00, 0f, 83, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 06, 00, 07, fb, 01, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 06, 00, 07, e7, 03, 02, 09, 00, 0a, d7, 02, 00, 10, 00, 1d, 7d, 00, 1e, 02, 06, d2, 02, 02, 0f, 00, 1c, ce, 02, 01, 0c, 00, 19, ca, 02, 00, 1d, 00, 2a, c6, 02, 00, 2e, 00, 3c, ef, 03, 00, 3d, 02, 0a, 8d, 01, 02, 0a, 00, 0b, eb, 03, 01, 09, 00, 17, 29, 02, 0d, 02, 0f, 8f, 04, 05, 09, 00, 0a, e7, 03, 00, 10, 00, 1d, 11, 00, 1e, 02, 06, e2, 03, 02, 0f, 00, 1c, de, 03, 01, 0c, 00, 19, da, 03, 00, 1d, 00, 2a, d6, 03, 00, 2e, 00, 3c, 97, 04, 00, 3d, 02, 0a, 21, 02, 0a, 00, 0b, 93, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, 8b, 04, 02, 01, 00, 02]
Raw bytes (784): 0x[01, 01, 8e, 01, 09, 33, 37, 41, 3b, 3d, 35, 39, 05, 00, b7, 04, 09, 05, 00, 0d, 35, 26, 39, 0d, 35, 3b, 3d, 35, 39, 37, 41, 3b, 3d, 35, 39, b2, 04, 0d, b7, 04, 09, 05, 00, 45, 00, 83, 01, 49, 45, 00, 7e, 31, 83, 01, 49, 45, 00, 7a, 4d, 7e, 31, 83, 01, 49, 45, 00, 76, 51, 7a, 4d, 7e, 31, 83, 01, 49, 45, 00, a7, 01, 55, 4d, 51, a3, 01, 59, a7, 01, 55, 4d, 51, 49, 9f, 01, a3, 01, 59, a7, 01, 55, 4d, 51, 61, 00, e3, 01, 65, 61, 00, de, 01, 2d, e3, 01, 65, 61, 00, da, 01, 69, de, 01, 2d, e3, 01, 65, 61, 00, d6, 01, 6d, da, 01, 69, de, 01, 2d, e3, 01, 65, 61, 00, 8b, 02, 71, 69, 6d, 87, 02, 75, 8b, 02, 71, 69, 6d, ff, 01, 00, 65, 83, 02, 87, 02, 75, 8b, 02, 71, 69, 6d, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 79, 00, d7, 02, 7d, 79, 00, d2, 02, 29, d7, 02, 7d, 79, 00, ce, 02, 81, 01, d2, 02, 29, d7, 02, 7d, 79, 00, ca, 02, 85, 01, ce, 02, 81, 01, d2, 02, 29, d7, 02, 7d, 79, 00, f3, 03, 89, 01, 81, 01, 85, 01, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 11, 93, 04, 97, 04, 21, 9b, 04, 1d, 15, 19, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, de, 03, 15, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, da, 03, 19, de, 03, 15, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 9b, 04, 1d, 15, 19, 97, 04, 21, 9b, 04, 1d, 15, 19, 8f, 04, 9f, 04, 11, 93, 04, 97, 04, 21, 9b, 04, 1d, 15, 19, a3, 04, ae, 04, a7, 04, 31, ab, 04, 2d, 25, 29, b2, 04, 0d, b7, 04, 09, 05, 00, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 06, 00, 07, 03, 03, 09, 00, 0a, b7, 04, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, b2, 04, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 26, 00, 1d, 00, 2a, 22, 00, 2e, 00, 3c, 37, 00, 3d, 02, 0a, 41, 02, 0a, 00, 0b, 33, 01, 09, 01, 12, ae, 04, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 83, 01, 02, 08, 00, 15, 49, 00, 16, 02, 06, 7e, 02, 0f, 00, 1c, 7a, 01, 0c, 00, 19, 76, 00, 1d, 00, 2a, 72, 00, 2e, 00, 3c, a3, 01, 00, 3d, 02, 0a, 59, 02, 0a, 00, 0b, 9f, 01, 01, 09, 00, 17, 31, 02, 09, 00, 0f, 9b, 01, 03, 08, 00, 0c, 5d, 01, 0d, 01, 10, 61, 01, 11, 02, 0a, 00, 02, 0a, 00, 0b, e3, 01, 02, 0c, 00, 19, 65, 00, 1a, 02, 0a, de, 01, 04, 11, 00, 1e, da, 01, 01, 10, 00, 1d, d6, 01, 00, 21, 00, 2e, d2, 01, 00, 32, 00, 40, 87, 02, 00, 41, 02, 0e, 75, 02, 0e, 00, 0f, 83, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 06, 00, 07, fb, 01, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 06, 00, 07, e7, 03, 02, 09, 00, 0a, d7, 02, 00, 10, 00, 1d, 7d, 00, 1e, 02, 06, d2, 02, 02, 0f, 00, 1c, ce, 02, 01, 0c, 00, 19, ca, 02, 00, 1d, 00, 2a, c6, 02, 00, 2e, 00, 3c, ef, 03, 00, 3d, 02, 0a, 8d, 01, 02, 0a, 00, 0b, eb, 03, 01, 09, 00, 17, 29, 02, 0d, 02, 0f, 8f, 04, 05, 09, 00, 0a, e7, 03, 00, 10, 00, 1d, 11, 00, 1e, 02, 06, e2, 03, 02, 0f, 00, 1c, de, 03, 01, 0c, 00, 19, da, 03, 00, 1d, 00, 2a, d6, 03, 00, 2e, 00, 3c, 97, 04, 00, 3d, 02, 0a, 21, 02, 0a, 00, 0b, 93, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, 8b, 04, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 142
Expand Down Expand Up @@ -197,7 +197,7 @@ Number of file 0 mappings: 68
- Code(Expression(56, Add)) at (prev + 2, 12) to (start + 0, 25)
= (c24 + Zero)
- Code(Counter(25)) at (prev + 0, 26) to (start + 2, 10)
- Code(Expression(55, Sub)) at (prev + 3, 17) to (start + 0, 30)
- Code(Expression(55, Sub)) at (prev + 4, 17) to (start + 0, 30)
= ((c24 + Zero) - c25)
- Code(Expression(54, Sub)) at (prev + 1, 16) to (start + 0, 29)
= (((c24 + Zero) - c25) - c11)
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/conditions.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
LL| 1| if countdown > 7 {
LL| 1| countdown -= 4;
LL| 1| }
LL| | //
LL| 0| else if countdown > 2 {
LL| 0| if countdown < 1 || countdown > 5 || countdown != 9 {
LL| 0| countdown = 0;
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn main() {
if countdown > 7 {
countdown -= 4;
}
//
else if countdown > 2 {
if countdown < 1 || countdown > 5 || countdown != 9 {
countdown = 0;
Expand Down
22 changes: 11 additions & 11 deletions tests/coverage/fn_sig_into_try.cov-map
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
Function name: fn_sig_into_try::a
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 04, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 05, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 10, 1) to (start + 4, 2)
- Code(Counter(0)) at (prev + 10, 1) to (start + 5, 2)

Function name: fn_sig_into_try::b
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 10, 01, 02, 0f, 00, 02, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 11, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Zero
- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 16, 1) to (start + 2, 15)
- Code(Zero) at (prev + 2, 15) to (start + 0, 16)
- Code(Counter(0)) at (prev + 17, 1) to (start + 3, 15)
- Code(Zero) at (prev + 3, 15) to (start + 0, 16)
- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
= (c0 - Zero)
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
= (Zero + (c0 - Zero))

Function name: fn_sig_into_try::c
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 16, 01, 02, 17, 00, 02, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 18, 01, 03, 17, 00, 03, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Zero
- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 22, 1) to (start + 2, 23)
- Code(Zero) at (prev + 2, 23) to (start + 0, 24)
- Code(Counter(0)) at (prev + 24, 1) to (start + 3, 23)
- Code(Zero) at (prev + 3, 23) to (start + 0, 24)
- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
= (c0 - Zero)
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
= (Zero + (c0 - Zero))

Function name: fn_sig_into_try::d
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 1f, 01, 04, 0f, 00, 04, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Zero
- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 28, 1) to (start + 3, 15)
- Code(Zero) at (prev + 3, 15) to (start + 0, 16)
- Code(Counter(0)) at (prev + 31, 1) to (start + 4, 15)
- Code(Zero) at (prev + 4, 15) to (start + 0, 16)
- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
= (c0 - Zero)
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
Expand Down
4 changes: 4 additions & 0 deletions tests/coverage/fn_sig_into_try.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@
LL| |// signature should be handled in the same way.
LL| |
LL| 1|fn a() -> Option<i32>
LL| 1|//
LL| 1|{
LL| 1| Some(7i32);
LL| 1| Some(0)
LL| 1|}
LL| |
LL| 1|fn b() -> Option<i32>
LL| 1|//
LL| 1|{
LL| 1| Some(7i32)?;
^0
LL| 1| Some(0)
LL| 1|}
LL| |
LL| 1|fn c() -> Option<i32>
LL| 1|//
LL| 1|{
LL| 1| let _ = Some(7i32)?;
^0
LL| 1| Some(0)
LL| 1|}
LL| |
LL| 1|fn d() -> Option<i32>
LL| 1|//
LL| 1|{
LL| 1| let _: () = ();
LL| 1| Some(7i32)?;
Expand Down
4 changes: 4 additions & 0 deletions tests/coverage/fn_sig_into_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@
// signature should be handled in the same way.

fn a() -> Option<i32>
//
{
Some(7i32);
Some(0)
}

fn b() -> Option<i32>
//
{
Some(7i32)?;
Some(0)
}

fn c() -> Option<i32>
//
{
let _ = Some(7i32)?;
Some(0)
}

fn d() -> Option<i32>
//
{
let _: () = ();
Some(7i32)?;
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/generics.coverage
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
LL| |#![allow(unused_assignments)]
LL| |// failure-status: 1
LL| |
LL| |struct Firework<T> where T: Copy + std::fmt::Display {
LL| |struct Firework<T: Copy + std::fmt::Display> {
LL| | strength: T,
LL| |}
LL| |
LL| |impl<T> Firework<T> where T: Copy + std::fmt::Display {
LL| |impl<T: Copy + std::fmt::Display> Firework<T> {
LL| | #[inline(always)]
LL| 3| fn set_strength(&mut self, new_strength: T) {
LL| 3| self.strength = new_strength;
Expand All @@ -23,7 +23,7 @@
------------------
LL| |}
LL| |
LL| |impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display {
LL| |impl<T: Copy + std::fmt::Display> Drop for Firework<T> {
LL| | #[inline(always)]
LL| 2| fn drop(&mut self) {
LL| 2| println!("BOOM times {}!!!", self.strength);
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/generics.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#![allow(unused_assignments)]
// failure-status: 1

struct Firework<T> where T: Copy + std::fmt::Display {
struct Firework<T: Copy + std::fmt::Display> {
strength: T,
}

impl<T> Firework<T> where T: Copy + std::fmt::Display {
impl<T: Copy + std::fmt::Display> Firework<T> {
#[inline(always)]
fn set_strength(&mut self, new_strength: T) {
self.strength = new_strength;
}
}

impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display {
impl<T: Copy + std::fmt::Display> Drop for Firework<T> {
#[inline(always)]
fn drop(&mut self) {
println!("BOOM times {}!!!", self.strength);
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/while.cov-map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Function name: while::main
Raw bytes (28): 0x[01, 01, 02, 01, 00, 03, 00, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02]
Raw bytes (28): 0x[01, 01, 02, 01, 00, 03, 00, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 02, 06, 06, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
Expand All @@ -9,7 +9,7 @@ Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16)
- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 20)
= (c0 + Zero)
- Code(Zero) at (prev + 0, 21) to (start + 1, 6)
- Code(Expression(1, Sub)) at (prev + 2, 1) to (start + 0, 2)
- Code(Zero) at (prev + 0, 21) to (start + 2, 6)
- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2)
= ((c0 + Zero) - Zero)

1 change: 1 addition & 0 deletions tests/coverage/while.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LL| 1|fn main() {
LL| 1| let num = 9;
LL| 1| while num >= 10 {
LL| 0| // loop body
LL| 0| }
LL| 1|}

1 change: 1 addition & 0 deletions tests/coverage/while.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fn main() {
let num = 9;
while num >= 10 {
// loop body
}
}

0 comments on commit 1f9353a

Please sign in to comment.