mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
zig fmt: add tests for cast builtin canonicalization
This commit is contained in:
parent
be51d69dc7
commit
2761cc8be0
@ -6056,6 +6056,25 @@ test "zig fmt: indentation of comments within catch, else, orelse" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: canonicalize cast builtins" {
|
||||
try testTransform(
|
||||
\\const foo = @alignCast(@ptrCast(bar));
|
||||
\\const baz = @constCast(@ptrCast(@addrSpaceCast(@volatileCast(@alignCast(bar)))));
|
||||
\\
|
||||
,
|
||||
\\const foo = @ptrCast(@alignCast(bar));
|
||||
\\const baz = @ptrCast(@alignCast(@addrSpaceCast(@constCast(@volatileCast(bar)))));
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: do not canonicalize invalid cast builtins" {
|
||||
try testCanonical(
|
||||
\\const foo = @alignCast(@volatileCast(@ptrCast(@alignCast(bar))));
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "recovery: top level" {
|
||||
try testError(
|
||||
\\test "" {inline}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user