Coverage tests for remaining TerminatorKinds and async, improve Assert
Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.
Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).
Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-11-16 11:14:28 -06:00
|
|
|
1| |#![allow(unused_assignments)]
|
|
|
|
2| |// expect-exit-status-101
|
|
|
|
3| |
|
2020-12-01 01:58:08 -06:00
|
|
|
4| 4|fn might_panic(should_panic: bool) {
|
Coverage tests for remaining TerminatorKinds and async, improve Assert
Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.
Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).
Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-11-16 11:14:28 -06:00
|
|
|
5| 4| if should_panic {
|
|
|
|
6| 1| println!("panicking...");
|
|
|
|
7| 1| panic!("panics");
|
|
|
|
8| 3| } else {
|
|
|
|
9| 3| println!("Don't Panic");
|
|
|
|
10| 3| }
|
|
|
|
11| 3|}
|
|
|
|
12| |
|
2020-12-01 01:58:08 -06:00
|
|
|
13| 1|fn main() -> Result<(), u8> {
|
Coverage tests for remaining TerminatorKinds and async, improve Assert
Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.
Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).
Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-11-16 11:14:28 -06:00
|
|
|
14| 1| let mut countdown = 10;
|
2020-12-16 01:33:47 -06:00
|
|
|
15| 11| while countdown > 0 {
|
|
|
|
16| 11| if countdown == 1 {
|
|
|
|
17| 1| might_panic(true);
|
Coverage tests for remaining TerminatorKinds and async, improve Assert
Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.
Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).
Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-11-16 11:14:28 -06:00
|
|
|
18| 10| } else if countdown < 5 {
|
|
|
|
19| 3| might_panic(false);
|
2020-12-01 01:58:08 -06:00
|
|
|
20| 6| }
|
2020-12-16 01:33:47 -06:00
|
|
|
21| 10| countdown -= 1;
|
Coverage tests for remaining TerminatorKinds and async, improve Assert
Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.
Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).
Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-11-16 11:14:28 -06:00
|
|
|
22| | }
|
|
|
|
23| 0| Ok(())
|
|
|
|
24| 0|}
|
|
|
|
25| |
|
|
|
|
26| |// Notes:
|
|
|
|
27| |// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and
|
|
|
|
28| |// `try_error_result.rs`.
|
|
|
|
29| |// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the
|
|
|
|
30| |// normal program exit cleanup, including writing out the current values of the coverage
|
|
|
|
31| |// counters.
|
|
|
|
|