Add a failing xcrate generator test

This commit is contained in:
Alex Crichton 2017-08-09 16:38:05 -07:00
parent e181060a59
commit be95ca4b17
2 changed files with 18 additions and 5 deletions

View File

@ -12,14 +12,16 @@
use std::ops::Generator;
fn bar() -> bool {
false
}
pub fn foo() -> impl Generator<Yield = (), Return = ()> {
|| {
if bar() {
if false {
yield;
}
}
}
pub fn bar<T: 'static>(t: T) -> Box<Generator<Yield = T, Return = ()>> {
Box::new(|| {
yield t;
})
}

View File

@ -23,4 +23,15 @@ fn main() {
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
let mut foo = xcrate::bar(3);
match foo.resume() {
GeneratorState::Yielded(4) => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
}