parser: port test "if condition wraps"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user