2024-04-11 08:15:34 -05:00
|
|
|
LL| |#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| |#![allow(unused_assignments)]
|
|
|
|
LL| |
|
2023-10-20 11:59:23 -05:00
|
|
|
LL| |use std::ops::{Coroutine, CoroutineState};
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| |use std::pin::Pin;
|
|
|
|
LL| |
|
|
|
|
LL| 1|fn main() {
|
2024-05-28 23:27:57 -05:00
|
|
|
LL| 1| let mut coroutine = #[coroutine]
|
|
|
|
LL| 1| || {
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 1| yield 1;
|
2023-08-16 20:43:10 -05:00
|
|
|
LL| 1| return "foo";
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 1| };
|
|
|
|
LL| |
|
2023-10-20 11:59:23 -05:00
|
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
|
|
LL| 1| CoroutineState::Yielded(1) => {}
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
2023-10-20 11:59:23 -05:00
|
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
|
|
LL| 1| CoroutineState::Complete("foo") => {}
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
|
|
|
LL| |
|
2024-05-28 23:27:57 -05:00
|
|
|
LL| 1| let mut coroutine = #[coroutine]
|
|
|
|
LL| 1| || {
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 1| yield 1;
|
|
|
|
LL| 1| yield 2;
|
|
|
|
LL| 0| yield 3;
|
2023-08-16 20:43:10 -05:00
|
|
|
LL| 0| return "foo";
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 0| };
|
|
|
|
LL| |
|
2023-10-20 11:59:23 -05:00
|
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
|
|
LL| 1| CoroutineState::Yielded(1) => {}
|
2023-08-15 21:42:33 -05:00
|
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
|
|
LL| | }
|
2023-10-20 11:59:23 -05:00
|
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
|
|
LL| 1| CoroutineState::Yielded(2) => {}
|
2023-08-15 21:42:33 -05:00
|
|
|
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 11:14:28 -06:00
|
|
|
|