3141177995
The output of these tests is too complicated to comfortably verify by hand, but we can still use them to observe changes to the underlying mappings produced by codegen/LLVM. If these tests fail due to non-coverage changes (e.g. in HIR-to-MIR lowering or MIR optimizations), it should usually be OK to just `--bless` them, as long as the `run-coverage` test suite still works.
38 lines
933 B
Rust
38 lines
933 B
Rust
#![feature(generators, generator_trait)]
|
|
#![allow(unused_assignments)]
|
|
|
|
use std::ops::{Generator, GeneratorState};
|
|
use std::pin::Pin;
|
|
|
|
fn main() {
|
|
let mut generator = || {
|
|
yield 1;
|
|
return "foo";
|
|
};
|
|
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Yielded(1) => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Complete("foo") => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
|
|
let mut generator = || {
|
|
yield 1;
|
|
yield 2;
|
|
yield 3;
|
|
return "foo";
|
|
};
|
|
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Yielded(1) => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Yielded(2) => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
}
|