| ... | ... | @@ -41,3 +41,21 @@ fn seq(c: u8) void { |
| 41 | 41 | points[index] = c; |
| 42 | 42 | index += 1; |
| 43 | 43 | } |
| 44 | |
| 45 | test "coroutine suspend with block" { |
| 46 | const p = (async(std.debug.global_allocator) testSuspendBlock()) catch unreachable; |
| 47 | std.debug.assert(!result); |
| 48 | resume a_promise; |
| 49 | std.debug.assert(result); |
| 50 | cancel p; |
| 51 | } |
| 52 | |
| 53 | var a_promise: promise = undefined; |
| 54 | var result = false; |
| 55 | |
| 56 | async fn testSuspendBlock() void { |
| 57 | suspend |p| { |
| 58 | a_promise = p; |
| 59 | } |
| 60 | result = true; |
| 61 | } |