rust/tests/ui/generator/xcrate.rs

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

31 lines
648 B
Rust
Raw Normal View History

// run-pass
2017-08-09 15:56:19 -05:00
// aux-build:xcrate.rs
2017-07-07 18:12:44 -05:00
#![feature(generators, generator_trait)]
2017-08-09 15:56:19 -05:00
extern crate xcrate;
use std::ops::{GeneratorState, Generator};
2018-10-04 13:49:38 -05:00
use std::pin::Pin;
2017-07-07 18:12:44 -05:00
fn main() {
2017-08-09 15:56:19 -05:00
let mut foo = xcrate::foo();
2017-07-07 18:12:44 -05:00
match Pin::new(&mut foo).resume(()) {
2017-08-09 15:56:19 -05:00
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
2017-08-09 18:38:05 -05:00
let mut foo = xcrate::bar(3);
match Pin::new(&mut foo).resume(()) {
2017-08-11 11:54:28 -05:00
GeneratorState::Yielded(3) => {}
2017-08-09 18:38:05 -05:00
s => panic!("bad state: {:?}", s),
}
match Pin::new(&mut foo).resume(()) {
2017-08-09 18:38:05 -05:00
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
2017-07-07 18:12:44 -05:00
}