authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-09 21:05:54-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-10 01:38:40-05:00
log20011a7a1c1f08644cd82a3c3e1d57cba9980695
treef2f9e4cce6c3581dc100c20c5867e4df6d2e46be
parent61a02d9d1e1a35469530a47f4aa710ac49e6efae

add behavior test for coroutine frame allocation failure


1 files changed, 13 insertions(+), 0 deletions(-)

test/cases/coroutines.zig+13
......@@ -130,3 +130,16 @@ fn early_seq(c: u8) void {
130130 early_points[early_seq_index] = c;
131131 early_seq_index += 1;
132132}
133
134test "coro allocation failure" {
135 var failing_allocator = std.debug.FailingAllocator.init(std.debug.global_allocator, 0);
136 if (async(&failing_allocator.allocator) asyncFuncThatNeverGetsRun()) {
137 @panic("expected allocation failure");
138 } else |err| switch (err) {
139 error.OutOfMemory => {},
140 }
141}
142
143async fn asyncFuncThatNeverGetsRun() void {
144 @panic("coro frame allocation should fail");
145}