File: branch_if.coverage

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,245,360 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (115 lines) | stat: -rw-r--r-- 3,359 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
   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|      3|fn branch_not(a: bool) {
   LL|      3|    no_merge!();
   LL|       |
   LL|      3|    if a {
  ------------------
  |  Branch (LL:8): [True: 2, False: 1]
  ------------------
   LL|      2|        say("a")
   LL|      1|    }
   LL|      3|    if !a {
  ------------------
  |  Branch (LL:8): [True: 1, False: 2]
  ------------------
   LL|      1|        say("not a");
   LL|      2|    }
   LL|      3|    if !!a {
  ------------------
  |  Branch (LL:8): [True: 2, False: 1]
  ------------------
   LL|      2|        say("not not a");
   LL|      2|    }
                   ^1
   LL|      3|    if !!!a {
  ------------------
  |  Branch (LL:8): [True: 1, False: 2]
  ------------------
   LL|      1|        say("not not not a");
   LL|      2|    }
   LL|      3|}
   LL|       |
   LL|      3|fn branch_not_as(a: bool) {
   LL|      3|    no_merge!();
   LL|       |
   LL|      3|    if !(a as bool) {
  ------------------
  |  Branch (LL:8): [True: 1, False: 2]
  ------------------
   LL|      1|        say("not (a as bool)");
   LL|      2|    }
   LL|      3|    if !!(a as bool) {
  ------------------
  |  Branch (LL:8): [True: 2, False: 1]
  ------------------
   LL|      2|        say("not not (a as bool)");
   LL|      2|    }
                   ^1
   LL|      3|    if !!!(a as bool) {
  ------------------
  |  Branch (LL:8): [True: 1, False: 2]
  ------------------
   LL|      1|        say("not not (a as bool)");
   LL|      2|    }
   LL|      3|}
   LL|       |
   LL|     15|fn branch_and(a: bool, b: bool) {
   LL|     15|    no_merge!();
   LL|       |
   LL|     15|    if a && b {
                          ^12
  ------------------
  |  Branch (LL:8): [True: 12, False: 3]
  |  Branch (LL:13): [True: 8, False: 4]
  ------------------
   LL|      8|        say("both");
   LL|      8|    } else {
   LL|      7|        say("not both");
   LL|      7|    }
   LL|     15|}
   LL|       |
   LL|     15|fn branch_or(a: bool, b: bool) {
   LL|     15|    no_merge!();
   LL|       |
   LL|     15|    if a || b {
                          ^3
  ------------------
  |  Branch (LL:8): [True: 12, False: 3]
  |  Branch (LL:13): [True: 2, False: 1]
  ------------------
   LL|     14|        say("either");
   LL|     14|    } else {
   LL|      1|        say("neither");
   LL|      1|    }
   LL|     15|}
   LL|       |
   LL|       |#[coverage(off)]
   LL|       |fn say(message: &str) {
   LL|       |    core::hint::black_box(message);
   LL|       |}
   LL|       |
   LL|       |#[coverage(off)]
   LL|       |fn main() {
   LL|       |    for a in [false, true, true] {
   LL|       |        branch_not(a);
   LL|       |        branch_not_as(a);
   LL|       |    }
   LL|       |
   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|       |}