parser: port test "if condition wraps"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-10 18:35:42 +00:00
parent a8bca43940
commit 6356c15c70

View File

@@ -1928,6 +1928,87 @@ test "zig fmt: 'zig fmt: on' indentation is unchanged" {
);
}
test "zig fmt: if condition wraps" {
try testTransform(
\\comptime {
\\ if (cond and
\\ cond) {
\\ return x;
\\ }
\\ while (cond and
\\ cond) {
\\ return x;
\\ }
\\ if (a == b and
\\ c) {
\\ a = b;
\\ }
\\ while (a == b and
\\ c) {
\\ a = b;
\\ }
\\ if ((cond and
\\ cond)) {
\\ return x;
\\ }
\\ while ((cond and
\\ cond)) {
\\ return x;
\\ }
\\ var a = if (a) |*f| x: {
\\ break :x &a.b;
\\ } else |err| err;
\\ var a = if (cond and
\\ cond) |*f|
\\ x: {
\\ break :x &a.b;
\\ } else |err| err;
\\}
,
\\comptime {
\\ if (cond and
\\ cond)
\\ {
\\ return x;
\\ }
\\ while (cond and
\\ cond)
\\ {
\\ return x;
\\ }
\\ if (a == b and
\\ c)
\\ {
\\ a = b;
\\ }
\\ while (a == b and
\\ c)
\\ {
\\ a = b;
\\ }
\\ if ((cond and
\\ cond))
\\ {
\\ return x;
\\ }
\\ while ((cond and
\\ cond))
\\ {
\\ return x;
\\ }
\\ var a = if (a) |*f| x: {
\\ break :x &a.b;
\\ } else |err| err;
\\ var a = if (cond and
\\ cond) |*f|
\\ x: {
\\ break :x &a.b;
\\ } else |err| err;
\\}
\\
);
}
test "zig fmt: pointer of unknown length" {
try testCanonical(
\\fn foo(ptr: [*]u8) void {}