Add a basic test for gen fn
This commit is contained in:
parent
f29b36d03e
commit
3887b1645a
1 changed files with 18 additions and 0 deletions
18
tests/ui/coroutine/gen_fn_iter.rs
Normal file
18
tests/ui/coroutine/gen_fn_iter.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// edition: 2024
|
||||
// compile-flags: -Zunstable-options
|
||||
// run-pass
|
||||
#![feature(gen_blocks)]
|
||||
|
||||
gen fn foo() -> i32 {
|
||||
yield 1;
|
||||
yield 2;
|
||||
yield 3;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut iter = foo();
|
||||
assert_eq!(iter.next(), Some(1));
|
||||
assert_eq!(iter.next(), Some(2));
|
||||
assert_eq!(iter.next(), Some(3));
|
||||
assert_eq!(iter.next(), None);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue