rust/tests/ui/coroutine/xcrate.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
650 B
Rust
Raw Normal View History

//@ run-pass
2017-08-09 20:56:19 +00:00
//@ aux-build:xcrate.rs
2023-10-19 21:46:28 +00:00
#![feature(coroutines, coroutine_trait)]
2017-07-07 23:12:44 +00:00
2017-08-09 20:56:19 +00:00
extern crate xcrate;
2023-10-19 16:06:43 +00:00
use std::ops::{Coroutine, CoroutineState};
2018-10-04 18:49:38 +00:00
use std::pin::Pin;
2017-07-07 23:12:44 +00:00
fn main() {
2017-08-09 20:56:19 +00:00
let mut foo = xcrate::foo();
2017-07-07 23:12:44 +00:00
match Pin::new(&mut foo).resume(()) {
2023-10-19 16:06:43 +00:00
CoroutineState::Complete(()) => {}
2017-08-09 20:56:19 +00:00
s => panic!("bad state: {:?}", s),
}
2017-08-09 23:38:05 +00:00
let mut foo = xcrate::bar(3);
match Pin::new(&mut foo).resume(()) {
2023-10-19 16:06:43 +00:00
CoroutineState::Yielded(3) => {}
2017-08-09 23:38:05 +00:00
s => panic!("bad state: {:?}", s),
}
match Pin::new(&mut foo).resume(()) {
2023-10-19 16:06:43 +00:00
CoroutineState::Complete(()) => {}
2017-08-09 23:38:05 +00:00
s => panic!("bad state: {:?}", s),
}
2017-07-07 23:12:44 +00:00
}