mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
add test for comptime-only functions
This commit is contained in:
@@ -770,3 +770,15 @@ test "return undefined pointer from function, directly and by expired local" {
|
||||
const bad_ptr_2 = S.returnStackPointer();
|
||||
_ = bad_ptr_2; // dereferencing this would be illegal behavior
|
||||
}
|
||||
|
||||
test "a function that works at comptime but not runtime" {
|
||||
const a = comptime testComptimeOnlyFn(1, 1);
|
||||
try expect(a[0] == 1);
|
||||
try expect(a[1] == 2);
|
||||
}
|
||||
|
||||
fn testComptimeOnlyFn(x: u32, y: u32) [2]u8 {
|
||||
const xa: [x]u8 = .{1};
|
||||
const ya: [y]u8 = .{2};
|
||||
return xa ++ ya;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user