about summary refs log tree commit diff
path: root/tests/coverage/branch/while.coverage
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2024-04-17 11:41:40 +1000
committerZalathar <Zalathar@users.noreply.github.com>2024-04-17 11:41:40 +1000
commit40cfc2de77a605a2b373c0767037065d304d556a (patch)
tree3888ac3aa319b1e93e312b2bd8ab2d575b237cfb /tests/coverage/branch/while.coverage
parent3fba2782310b2754259a3c329220a5b1e6cf9a5c (diff)
downloadrust-40cfc2de77a605a2b373c0767037065d304d556a.tar.gz
rust-40cfc2de77a605a2b373c0767037065d304d556a.zip
coverage: Move branch coverage tests into a subdirectory
Diffstat (limited to 'tests/coverage/branch/while.coverage')
-rw-r--r--tests/coverage/branch/while.coverage74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/coverage/branch/while.coverage b/tests/coverage/branch/while.coverage
new file mode 100644
index 00000000000..8d9a6c3bc68
--- /dev/null
+++ b/tests/coverage/branch/while.coverage
@@ -0,0 +1,74 @@
+   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|      1|fn while_cond() {
+   LL|      1|    no_merge!();
+   LL|       |
+   LL|      1|    let mut a = 8;
+   LL|      9|    while a > 0 {
+  ------------------
+  |  Branch (LL:11): [True: 8, False: 1]
+  ------------------
+   LL|      8|        a -= 1;
+   LL|      8|    }
+   LL|      1|}
+   LL|       |
+   LL|      1|fn while_cond_not() {
+   LL|      1|    no_merge!();
+   LL|       |
+   LL|      1|    let mut a = 8;
+   LL|      9|    while !(a == 0) {
+  ------------------
+  |  Branch (LL:11): [True: 8, False: 1]
+  ------------------
+   LL|      8|        a -= 1;
+   LL|      8|    }
+   LL|      1|}
+   LL|       |
+   LL|      1|fn while_op_and() {
+   LL|      1|    no_merge!();
+   LL|       |
+   LL|      1|    let mut a = 8;
+   LL|      1|    let mut b = 4;
+   LL|      5|    while a > 0 && b > 0 {
+  ------------------
+  |  Branch (LL:11): [True: 5, False: 0]
+  |  Branch (LL:20): [True: 4, False: 1]
+  ------------------
+   LL|      4|        a -= 1;
+   LL|      4|        b -= 1;
+   LL|      4|    }
+   LL|      1|}
+   LL|       |
+   LL|      1|fn while_op_or() {
+   LL|      1|    no_merge!();
+   LL|       |
+   LL|      1|    let mut a = 4;
+   LL|      1|    let mut b = 8;
+   LL|      9|    while a > 0 || b > 0 {
+                                 ^5
+  ------------------
+  |  Branch (LL:11): [True: 4, False: 5]
+  |  Branch (LL:20): [True: 4, False: 1]
+  ------------------
+   LL|      8|        a -= 1;
+   LL|      8|        b -= 1;
+   LL|      8|    }
+   LL|      1|}
+   LL|       |
+   LL|       |#[coverage(off)]
+   LL|       |fn main() {
+   LL|       |    while_cond();
+   LL|       |    while_cond_not();
+   LL|       |    while_op_and();
+   LL|       |    while_op_or();
+   LL|       |}
+