|
|
|
|
@ -8,6 +8,9 @@ const expectError = std.testing.expectError;
|
|
|
|
|
var global_x: i32 = 1;
|
|
|
|
|
|
|
|
|
|
test "simple coroutine suspend and resume" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
var frame = async simpleAsyncFn();
|
|
|
|
|
try expect(global_x == 2);
|
|
|
|
|
resume frame;
|
|
|
|
|
@ -28,6 +31,9 @@ fn simpleAsyncFn() void {
|
|
|
|
|
var global_y: i32 = 1;
|
|
|
|
|
|
|
|
|
|
test "pass parameter to coroutine" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
var p = async simpleAsyncFnWithArg(2);
|
|
|
|
|
try expect(global_y == 3);
|
|
|
|
|
resume p;
|
|
|
|
|
@ -40,6 +46,9 @@ fn simpleAsyncFnWithArg(delta: i32) void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "suspend at end of function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var x: i32 = 1;
|
|
|
|
|
|
|
|
|
|
@ -59,6 +68,9 @@ test "suspend at end of function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "local variable in async function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var x: i32 = 0;
|
|
|
|
|
|
|
|
|
|
@ -88,6 +100,9 @@ test "local variable in async function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "calling an inferred async function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var x: i32 = 1;
|
|
|
|
|
var other_frame: *@Frame(other) = undefined;
|
|
|
|
|
@ -112,6 +127,9 @@ test "calling an inferred async function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@frameSize" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
if (builtin.target.cpu.arch == .thumb or builtin.target.cpu.arch == .thumbeb)
|
|
|
|
|
return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
@ -143,6 +161,9 @@ test "@frameSize" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "coroutine suspend, resume" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -184,6 +205,9 @@ test "coroutine suspend, resume" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "coroutine suspend with block" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const p = async testSuspendBlock();
|
|
|
|
|
_ = p;
|
|
|
|
|
try expect(!global_result);
|
|
|
|
|
@ -210,6 +234,9 @@ var await_a_promise: anyframe = undefined;
|
|
|
|
|
var await_final_result: i32 = 0;
|
|
|
|
|
|
|
|
|
|
test "coroutine await" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
await_seq('a');
|
|
|
|
|
var p = async await_amain();
|
|
|
|
|
_ = p;
|
|
|
|
|
@ -247,6 +274,9 @@ fn await_seq(c: u8) void {
|
|
|
|
|
var early_final_result: i32 = 0;
|
|
|
|
|
|
|
|
|
|
test "coroutine await early return" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
early_seq('a');
|
|
|
|
|
var p = async early_amain();
|
|
|
|
|
_ = p;
|
|
|
|
|
@ -275,6 +305,9 @@ fn early_seq(c: u8) void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async function with dot syntax" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var y: i32 = 1;
|
|
|
|
|
fn foo() callconv(.Async) void {
|
|
|
|
|
@ -288,6 +321,9 @@ test "async function with dot syntax" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async fn pointer in a struct field" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
var data: i32 = 1;
|
|
|
|
|
const Foo = struct {
|
|
|
|
|
bar: fn (*i32) callconv(.Async) void,
|
|
|
|
|
@ -313,6 +349,9 @@ fn simpleAsyncFn2(y: *i32) callconv(.Async) void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@asyncCall with return type" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const Foo = struct {
|
|
|
|
|
bar: fn () callconv(.Async) i32,
|
|
|
|
|
|
|
|
|
|
@ -337,6 +376,9 @@ test "@asyncCall with return type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async fn with inferred error set" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -367,6 +409,9 @@ test "async fn with inferred error set" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "error return trace across suspend points - early return" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const p = nonFailing();
|
|
|
|
|
resume p;
|
|
|
|
|
const p2 = async printTrace(p);
|
|
|
|
|
@ -374,6 +419,9 @@ test "error return trace across suspend points - early return" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "error return trace across suspend points - async return" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const p = nonFailing();
|
|
|
|
|
const p2 = async printTrace(p);
|
|
|
|
|
_ = p2;
|
|
|
|
|
@ -404,6 +452,9 @@ fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "break from suspend" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
var my_result: i32 = 1;
|
|
|
|
|
const p = async testBreakFromSuspend(&my_result);
|
|
|
|
|
_ = p;
|
|
|
|
|
@ -419,6 +470,9 @@ fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "heap allocated async function frame" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var x: i32 = 42;
|
|
|
|
|
|
|
|
|
|
@ -443,6 +497,9 @@ test "heap allocated async function frame" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async function call return value" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
var pt = Point{ .x = 10, .y = 11 };
|
|
|
|
|
@ -484,6 +541,9 @@ test "async function call return value" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "suspension points inside branching control flow" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var result: i32 = 10;
|
|
|
|
|
|
|
|
|
|
@ -510,6 +570,9 @@ test "suspension points inside branching control flow" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "call async function which has struct return type" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -543,6 +606,9 @@ test "call async function which has struct return type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "pass string literal to async function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
var ok: bool = false;
|
|
|
|
|
@ -564,6 +630,9 @@ test "pass string literal to async function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "await inside an errdefer" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -587,6 +656,9 @@ test "await inside an errdefer" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "try in an async function with error union and non-zero-bit payload" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
var ok = false;
|
|
|
|
|
@ -617,6 +689,9 @@ test "try in an async function with error union and non-zero-bit payload" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "returning a const error from async function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
var ok = false;
|
|
|
|
|
@ -648,6 +723,9 @@ test "returning a const error from async function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async/await typical usage" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
inline for ([_]bool{ false, true }) |b1| {
|
|
|
|
|
inline for ([_]bool{ false, true }) |b2| {
|
|
|
|
|
inline for ([_]bool{ false, true }) |b3| {
|
|
|
|
|
@ -743,6 +821,9 @@ fn testAsyncAwaitTypicalUsage(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "alignment of local variables in async functions" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn doTheTest() !void {
|
|
|
|
|
var y: u8 = 123;
|
|
|
|
|
@ -755,6 +836,9 @@ test "alignment of local variables in async functions" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "no reason to resolve frame still works" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
_ = async simpleNothing();
|
|
|
|
|
}
|
|
|
|
|
fn simpleNothing() void {
|
|
|
|
|
@ -763,6 +847,9 @@ fn simpleNothing() void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async call a generic function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn doTheTest() !void {
|
|
|
|
|
var f = async func(i32, 2);
|
|
|
|
|
@ -783,6 +870,9 @@ test "async call a generic function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "return from suspend block" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn doTheTest() !void {
|
|
|
|
|
expect(func() == 1234) catch @panic("test failure");
|
|
|
|
|
@ -797,6 +887,9 @@ test "return from suspend block" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "struct parameter to async function is copied to the frame" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
const Point = struct {
|
|
|
|
|
x: i32,
|
|
|
|
|
@ -841,6 +934,9 @@ test "struct parameter to async function is copied to the frame" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "cast fn to async fn when it is inferred to be async" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
var ok = false;
|
|
|
|
|
@ -869,6 +965,9 @@ test "cast fn to async fn when it is inferred to be async" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "cast fn to async fn when it is inferred to be async, awaited directly" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var frame: anyframe = undefined;
|
|
|
|
|
var ok = false;
|
|
|
|
|
@ -896,6 +995,9 @@ test "cast fn to async fn when it is inferred to be async, awaited directly" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "await does not force async if callee is blocking" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn simple() i32 {
|
|
|
|
|
return 1234;
|
|
|
|
|
@ -906,6 +1008,9 @@ test "await does not force async if callee is blocking" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "recursive async function" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
try expect(recursiveAsyncFunctionTest(false).doTheTest() == 55);
|
|
|
|
|
try expect(recursiveAsyncFunctionTest(true).doTheTest() == 55);
|
|
|
|
|
}
|
|
|
|
|
@ -968,6 +1073,9 @@ fn recursiveAsyncFunctionTest(comptime suspending_implementation: bool) type {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@asyncCall with comptime-known function, but not awaited directly" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -997,6 +1105,9 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@asyncCall with actual frame instead of byte buffer" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn func() i32 {
|
|
|
|
|
suspend {}
|
|
|
|
|
@ -1011,6 +1122,9 @@ test "@asyncCall with actual frame instead of byte buffer" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@asyncCall using the result location inside the frame" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn simple2(y: *i32) callconv(.Async) i32 {
|
|
|
|
|
defer y.* += 2;
|
|
|
|
|
@ -1038,6 +1152,9 @@ test "@asyncCall using the result location inside the frame" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@TypeOf an async function call of generic fn with error union type" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn func(comptime x: anytype) anyerror!i32 {
|
|
|
|
|
const T = @TypeOf(async func(x));
|
|
|
|
|
@ -1049,6 +1166,9 @@ test "@TypeOf an async function call of generic fn with error union type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "using @TypeOf on a generic function call" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_ok = false;
|
|
|
|
|
@ -1074,6 +1194,9 @@ test "using @TypeOf on a generic function call" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "recursive call of await @asyncCall with struct return type" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_ok = false;
|
|
|
|
|
@ -1110,6 +1233,9 @@ test "recursive call of await @asyncCall with struct return type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "nosuspend function call" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn doTheTest() !void {
|
|
|
|
|
const result = nosuspend add(50, 100);
|
|
|
|
|
@ -1126,6 +1252,9 @@ test "nosuspend function call" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "await used in expression and awaiting fn with no suspend but async calling convention" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn atest() void {
|
|
|
|
|
var f1 = async add(1, 2);
|
|
|
|
|
@ -1142,6 +1271,9 @@ test "await used in expression and awaiting fn with no suspend but async calling
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "await used in expression after a fn call" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn atest() void {
|
|
|
|
|
var f1 = async add(3, 4);
|
|
|
|
|
@ -1160,6 +1292,9 @@ test "await used in expression after a fn call" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async fn call used in expression after a fn call" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
fn atest() void {
|
|
|
|
|
var sum: i32 = 0;
|
|
|
|
|
@ -1177,6 +1312,9 @@ test "async fn call used in expression after a fn call" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "suspend in for loop" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: ?anyframe = null;
|
|
|
|
|
|
|
|
|
|
@ -1203,6 +1341,9 @@ test "suspend in for loop" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "suspend in while loop" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: ?anyframe = null;
|
|
|
|
|
|
|
|
|
|
@ -1240,6 +1381,9 @@ test "suspend in while loop" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "correctly spill when returning the error union result of another async fn" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -1263,6 +1407,9 @@ test "correctly spill when returning the error union result of another async fn"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "spill target expr in a for loop" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -1294,6 +1441,9 @@ test "spill target expr in a for loop" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "spill target expr in a for loop, with a var decl in the loop body" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
|
|
|
|
|
@ -1330,6 +1480,9 @@ test "spill target expr in a for loop, with a var decl in the loop body" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async call with @call" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
fn doTheTest() void {
|
|
|
|
|
@ -1352,6 +1505,9 @@ test "async call with @call" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async function passed 0-bit arg after non-0-bit arg" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_int: i32 = 0;
|
|
|
|
|
@ -1373,6 +1529,9 @@ test "async function passed 0-bit arg after non-0-bit arg" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async function passed align(16) arg after align(8) arg" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_int: u128 = 0;
|
|
|
|
|
@ -1395,6 +1554,9 @@ test "async function passed align(16) arg after align(8) arg" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async function call resolves target fn frame, comptime func" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_int: i32 = 9;
|
|
|
|
|
@ -1417,6 +1579,9 @@ test "async function call resolves target fn frame, comptime func" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "async function call resolves target fn frame, runtime func" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_int: i32 = 9;
|
|
|
|
|
@ -1440,6 +1605,9 @@ test "async function call resolves target fn frame, runtime func" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "properly spill optional payload capture value" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var global_int: usize = 2;
|
|
|
|
|
@ -1464,6 +1632,9 @@ test "properly spill optional payload capture value" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "handle defer interfering with return value spill" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame1: anyframe = undefined;
|
|
|
|
|
var global_frame2: anyframe = undefined;
|
|
|
|
|
@ -1504,6 +1675,9 @@ test "handle defer interfering with return value spill" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "take address of temporary async frame" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var global_frame: anyframe = undefined;
|
|
|
|
|
var finished = false;
|
|
|
|
|
@ -1533,6 +1707,9 @@ test "take address of temporary async frame" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "nosuspend await" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var finished = false;
|
|
|
|
|
|
|
|
|
|
@ -1554,6 +1731,9 @@ test "nosuspend await" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "nosuspend on function calls" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S0 = struct {
|
|
|
|
|
b: i32 = 42,
|
|
|
|
|
};
|
|
|
|
|
@ -1570,6 +1750,9 @@ test "nosuspend on function calls" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "nosuspend on async function calls" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S0 = struct {
|
|
|
|
|
b: i32 = 42,
|
|
|
|
|
};
|
|
|
|
|
@ -1588,6 +1771,7 @@ test "nosuspend on async function calls" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// test "resume nosuspend async function calls" {
|
|
|
|
|
// if (builtin.zig_backend != .stage1) return error.SkipZigTest; // if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
// const S0 = struct {
|
|
|
|
|
// b: i32 = 42,
|
|
|
|
|
// };
|
|
|
|
|
@ -1610,6 +1794,9 @@ test "nosuspend on async function calls" {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
test "nosuspend resume async function calls" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S0 = struct {
|
|
|
|
|
b: i32 = 42,
|
|
|
|
|
};
|
|
|
|
|
@ -1632,6 +1819,9 @@ test "nosuspend resume async function calls" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "avoid forcing frame alignment resolution implicit cast to *anyopaque" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const S = struct {
|
|
|
|
|
var x: ?*anyopaque = null;
|
|
|
|
|
|
|
|
|
|
@ -1648,6 +1838,9 @@ test "avoid forcing frame alignment resolution implicit cast to *anyopaque" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@asyncCall with pass-by-value arguments" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const F0: u64 = 0xbeefbeefbeefbeef;
|
|
|
|
|
const F1: u64 = 0xf00df00df00df00d;
|
|
|
|
|
const F2: u64 = 0xcafecafecafecafe;
|
|
|
|
|
@ -1681,6 +1874,9 @@ test "@asyncCall with pass-by-value arguments" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "@asyncCall with arguments having non-standard alignment" {
|
|
|
|
|
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
|
|
|
|
if (builtin.os.tag == .wasi) return error.SkipZigTest; // TODO
|
|
|
|
|
|
|
|
|
|
const F0: u64 = 0xbeefbeef;
|
|
|
|
|
const F1: u64 = 0xf00df00df00df00d;
|
|
|
|
|
|
|
|
|
|
|