Add a basic test for gen fn

This commit is contained in:
Eric Holk 2023-11-30 11:20:53 -08:00
parent f29b36d03e
commit 3887b1645a
No known key found for this signature in database
GPG Key ID: 8EA6B43ED4CE0911

View 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);
}