diff --git a/test/cases/coroutines.zig b/test/cases/coroutines.zig index d5469a5d03ec7bb5a5559b9ac83d959719d3bfd2..12235cf40b5074c897a849722b7c4bf45b8c1b4d 100644 --- a/test/cases/coroutines.zig +++ b/test/cases/coroutines.zig @@ -130,3 +130,16 @@ fn early_seq(c: u8) void { early_points[early_seq_index] = c; early_seq_index += 1; } + +test "coro allocation failure" { + var failing_allocator = std.debug.FailingAllocator.init(std.debug.global_allocator, 0); + if (async(&failing_allocator.allocator) asyncFuncThatNeverGetsRun()) { + @panic("expected allocation failure"); + } else |err| switch (err) { + error.OutOfMemory => {}, + } +} + +async fn asyncFuncThatNeverGetsRun() void { + @panic("coro frame allocation should fail"); +}