mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add a failing xcrate generator test
This commit is contained in:
parent
e181060a59
commit
be95ca4b17
@ -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;
|
||||
})
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user