diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-03 02:11:52 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-03 02:11:52 -0400 |
| commit | e444e737b786afd0c5aba2ea04c901f89c57813e (patch) | |
| tree | 6740bacbb1cb2189a5a9715af9046f921c8f6319 /test/runtime_safety.zig | |
| parent | 24d78177eec4d8fc3aa8ca99dd50788e38f9f8b6 (diff) | |
| download | zig-e444e737b786afd0c5aba2ea04c901f89c57813e.tar.gz zig-e444e737b786afd0c5aba2ea04c901f89c57813e.zip | |
add runtime safety for resuming an awaiting function
Diffstat (limited to 'test/runtime_safety.zig')
| -rw-r--r-- | test/runtime_safety.zig | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 336dbb8bf0..43cf0856c3 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -1,6 +1,38 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompareOutputContext) void { + cases.addRuntimeSafety("resuming a function which is awaiting a frame", + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ @import("std").os.exit(126); + \\} + \\pub fn main() void { + \\ var frame = async first(); + \\ resume frame; + \\} + \\fn first() void { + \\ var frame = async other(); + \\ await frame; + \\} + \\fn other() void { + \\ suspend; + \\} + ); + cases.addRuntimeSafety("resuming a function which is awaiting a call", + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ @import("std").os.exit(126); + \\} + \\pub fn main() void { + \\ var frame = async first(); + \\ resume frame; + \\} + \\fn first() void { + \\ other(); + \\} + \\fn other() void { + \\ suspend; + \\} + ); + cases.addRuntimeSafety("invalid resume of async function", \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { \\ @import("std").os.exit(126); |
