mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Add C implementations for testing functions in zig
This commit is contained in:
parent
e95c5f9a9d
commit
bf582b8120
2 changed files with 23 additions and 2 deletions
|
@ -146,8 +146,9 @@ comptime {
|
||||||
exportUtilsFn(utils.increfC, "incref");
|
exportUtilsFn(utils.increfC, "incref");
|
||||||
exportUtilsFn(utils.decrefC, "decref");
|
exportUtilsFn(utils.decrefC, "decref");
|
||||||
exportUtilsFn(utils.decrefCheckNullC, "decref_check_null");
|
exportUtilsFn(utils.decrefCheckNullC, "decref_check_null");
|
||||||
exportUtilsFn(utils.expectFailed, "expect_failed");
|
exportUtilsFn(utils.expectFailedC, "expect_failed");
|
||||||
exportUtilsFn(utils.getExpectFailures, "get_expect_failures");
|
exportUtilsFn(utils.getExpectFailuresC, "get_expect_failures");
|
||||||
|
exportUtilsFn(utils.deinitFailuresC, "deinit_failures");
|
||||||
|
|
||||||
@export(utils.panic, .{ .name = "roc_builtins.utils." ++ "panic", .linkage = .Weak });
|
@export(utils.panic, .{ .name = "roc_builtins.utils." ++ "panic", .linkage = .Weak });
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,15 +251,35 @@ pub fn expectFailed(
|
||||||
failure_length += 1;
|
failure_length += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn expectFailedC (
|
||||||
|
start_line: u32,
|
||||||
|
end_line: u32,
|
||||||
|
start_col: u16,
|
||||||
|
end_col: u16,
|
||||||
|
) callconv(.C) void {
|
||||||
|
return @call(.{ .modifier = always_inline }, expectFailed, .{ start_line, end_line, start_col, end_col });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn getExpectFailures() []Failure {
|
pub fn getExpectFailures() []Failure {
|
||||||
return failures[0..failure_length];
|
return failures[0..failure_length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getExpectFailuresC() callconv(.C) *c_void {
|
||||||
|
var bytes = @ptrCast(*c_void, failures);
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn deinitFailures() void {
|
pub fn deinitFailures() void {
|
||||||
roc_dealloc(failures, @alignOf(Failure));
|
roc_dealloc(failures, @alignOf(Failure));
|
||||||
failure_length = 0;
|
failure_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn deinitFailuresC() callconv(.C) void {
|
||||||
|
return @call(.{ .modifier = always_inline }, deinitFailures, .{});
|
||||||
|
}
|
||||||
|
|
||||||
pub fn unsafeReallocate(
|
pub fn unsafeReallocate(
|
||||||
source_ptr: [*]u8,
|
source_ptr: [*]u8,
|
||||||
alignment: u32,
|
alignment: u32,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue