| ... | ... | @@ -333,3 +333,27 @@ async fn testBreakFromSuspend(my_result: *i32) void { |
| 333 | 333 | suspend; |
| 334 | 334 | my_result.* += 1; |
| 335 | 335 | } |
| 336 | |
| 337 | test "heap allocated async function frame" { |
| 338 | const S = struct { |
| 339 | var x: i32 = 42; |
| 340 | |
| 341 | fn doTheTest() !void { |
| 342 | const frame = try std.heap.direct_allocator.create(@Frame(someFunc)); |
| 343 | defer std.heap.direct_allocator.destroy(frame); |
| 344 | |
| 345 | expect(x == 42); |
| 346 | frame.* = async someFunc(); |
| 347 | expect(x == 43); |
| 348 | resume frame; |
| 349 | expect(x == 44); |
| 350 | } |
| 351 | |
| 352 | fn someFunc() void { |
| 353 | x += 1; |
| 354 | suspend; |
| 355 | x += 1; |
| 356 | } |
| 357 | }; |
| 358 | try S.doTheTest(); |
| 359 | } |