about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2023-11-30 11:20:53 -0800
committerEric Holk <ericholk@microsoft.com>2023-12-04 11:23:08 -0800
commit3887b1645aaa85e2755a54ab91f40c4fedc1dc0f (patch)
tree444bd4719630b0a4adb2de2f2d794e96f5ff019b /tests
parentf29b36d03ecf9986ac6c47385ff9390c9a2390e6 (diff)
downloadrust-3887b1645aaa85e2755a54ab91f40c4fedc1dc0f.tar.gz
rust-3887b1645aaa85e2755a54ab91f40c4fedc1dc0f.zip
Add a basic test for gen fn
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/coroutine/gen_fn_iter.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/coroutine/gen_fn_iter.rs b/tests/ui/coroutine/gen_fn_iter.rs
new file mode 100644
index 00000000000..222ab571415
--- /dev/null
+++ b/tests/ui/coroutine/gen_fn_iter.rs
@@ -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);
+}