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| |#![feature(generators, generator_trait)]
|
|
|
|
2| |#![allow(unused_assignments)]
|
|
|
|
3| |
|
|
|
|
4| |use std::ops::{Generator, GeneratorState};
|
|
|
|
5| |use std::pin::Pin;
|
|
|
|
6| |
|
2020-12-01 01:58:08 -06:00
|
|
|
7| 1|fn main() {
|
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
|
|
|
8| 1| let mut generator = || {
|
|
|
|
9| 1| yield 1;
|
|
|
|
10| 1| return "foo"
|
2022-09-05 08:42:17 -05:00
|
|
|
11| 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
|
|
|
12| |
|
|
|
|
13| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
14| 1| GeneratorState::Yielded(1) => {}
|
|
|
|
15| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
16| | }
|
|
|
|
17| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
18| 1| GeneratorState::Complete("foo") => {}
|
|
|
|
19| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
20| | }
|
|
|
|
21| |
|
|
|
|
22| 1| let mut generator = || {
|
|
|
|
23| 1| yield 1;
|
|
|
|
24| 1| yield 2;
|
|
|
|
25| 0| yield 3;
|
|
|
|
26| 0| return "foo"
|
2022-09-05 08:42:17 -05:00
|
|
|
27| 0| };
|
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
|
|
|
28| |
|
|
|
|
29| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
30| 1| GeneratorState::Yielded(1) => {}
|
|
|
|
31| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
32| | }
|
|
|
|
33| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
34| 1| GeneratorState::Yielded(2) => {}
|
|
|
|
35| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
36| | }
|
|
|
|
37| 1|}
|
|
|
|
|