2023-08-16 02:42:33 +00:00
|
|
|
LL| |#![feature(generators, generator_trait)]
|
|
|
|
LL| |#![allow(unused_assignments)]
|
|
|
|
LL| |
|
|
|
|
LL| |use std::ops::{Generator, GeneratorState};
|
|
|
|
LL| |use std::pin::Pin;
|
|
|
|
LL| |
|
|
|
|
LL| 1|fn main() {
|
|
|
|
LL| 1| let mut generator = || {
|
|
|
|
LL| 1| yield 1;
|
2023-08-17 01:43:10 +00:00
|
|
|
LL| 1| return "foo";
|
2023-08-16 02:42:33 +00:00
|
|
|
LL| 1| };
|
|
|
|
LL| |
|
|
|
|
LL| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
LL| 1| GeneratorState::Yielded(1) => {}
|
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
|
|
|
LL| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
LL| 1| GeneratorState::Complete("foo") => {}
|
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
|
|
|
LL| |
|
|
|
|
LL| 1| let mut generator = || {
|
|
|
|
LL| 1| yield 1;
|
|
|
|
LL| 1| yield 2;
|
|
|
|
LL| 0| yield 3;
|
2023-08-17 01:43:10 +00:00
|
|
|
LL| 0| return "foo";
|
2023-08-16 02:42:33 +00:00
|
|
|
LL| 0| };
|
|
|
|
LL| |
|
|
|
|
LL| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
LL| 1| GeneratorState::Yielded(1) => {}
|
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
|
|
|
LL| 1| match Pin::new(&mut generator).resume(()) {
|
|
|
|
LL| 1| GeneratorState::Yielded(2) => {}
|
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
|
|
|
LL| 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 17:14:28 +00:00
|
|
|
|