File: panic_unwind.coverage

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (32 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (4)
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
   LL|       |#![allow(unused_assignments)]
   LL|       |//@ failure-status: 101
   LL|       |
   LL|      4|fn might_panic(should_panic: bool) {
   LL|      4|    if should_panic {
   LL|      1|        println!("panicking...");
   LL|      1|        panic!("panics");
   LL|      3|    } else {
   LL|      3|        println!("Don't Panic");
   LL|      3|    }
   LL|      3|}
   LL|       |
   LL|      1|fn main() -> Result<(), u8> {
   LL|      1|    let mut countdown = 10;
   LL|     11|    while countdown > 0 {
   LL|     11|        if countdown == 1 {
   LL|      1|            might_panic(true);
   LL|     10|        } else if countdown < 5 {
   LL|      3|            might_panic(false);
   LL|      6|        }
   LL|     10|        countdown -= 1;
   LL|       |    }
   LL|      0|    Ok(())
   LL|      0|}
   LL|       |
   LL|       |// Notes:
   LL|       |//   1. Compare this program and its coverage results to those of the similar tests `abort.rs` and
   LL|       |//      `try_error_result.rs`.
   LL|       |//   2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the
   LL|       |//      normal program exit cleanup, including writing out the current values of the coverage
   LL|       |//      counters.