mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
zig fmt: struct literal containing a multiline expression
I modified this test case to expect different results. Now, the trailing comma on a list of struct fields is the only deciding factor, not whether or not the field init expressions contain a newline.
This commit is contained in:
parent
8379fff804
commit
1253903fef
@ -1594,50 +1594,67 @@ test "zig fmt: struct literal no trailing comma" {
|
||||
);
|
||||
}
|
||||
|
||||
//test "zig fmt: struct literal containing a multiline expression" {
|
||||
// try testTransform(
|
||||
// \\const a = A{ .x = if (f1()) 10 else 20 };
|
||||
// \\const a = A{ .x = if (f1()) 10 else 20, };
|
||||
// \\const a = A{ .x = if (f1())
|
||||
// \\ 10 else 20 };
|
||||
// \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 };
|
||||
// \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100, };
|
||||
// \\const a = A{ .x = if (f1())
|
||||
// \\ 10 else 20};
|
||||
// \\const a = A{ .x = switch(g) {0 => "ok", else => "no"} };
|
||||
// \\
|
||||
// ,
|
||||
// \\const a = A{ .x = if (f1()) 10 else 20 };
|
||||
// \\const a = A{
|
||||
// \\ .x = if (f1()) 10 else 20,
|
||||
// \\};
|
||||
// \\const a = A{
|
||||
// \\ .x = if (f1())
|
||||
// \\ 10
|
||||
// \\ else
|
||||
// \\ 20,
|
||||
// \\};
|
||||
// \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 };
|
||||
// \\const a = A{
|
||||
// \\ .x = if (f1()) 10 else 20,
|
||||
// \\ .y = f2() + 100,
|
||||
// \\};
|
||||
// \\const a = A{
|
||||
// \\ .x = if (f1())
|
||||
// \\ 10
|
||||
// \\ else
|
||||
// \\ 20,
|
||||
// \\};
|
||||
// \\const a = A{
|
||||
// \\ .x = switch (g) {
|
||||
// \\ 0 => "ok",
|
||||
// \\ else => "no",
|
||||
// \\ },
|
||||
// \\};
|
||||
// \\
|
||||
// );
|
||||
//}
|
||||
//
|
||||
test "zig fmt: struct literal containing a multiline expression" {
|
||||
try testTransform(
|
||||
\\const a = A{ .x = if (f1()) 10 else 20 };
|
||||
\\const a = A{ .x = if (f1()) 10 else 20, };
|
||||
\\const a = A{ .x = if (f1())
|
||||
\\ 10 else 20 };
|
||||
\\const a = A{ .x = if (f1())
|
||||
\\ 10 else 20,};
|
||||
\\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 };
|
||||
\\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100, };
|
||||
\\const a = A{ .x = if (f1())
|
||||
\\ 10 else 20};
|
||||
\\const a = A{ .x = if (f1())
|
||||
\\ 10 else 20,};
|
||||
\\const a = A{ .x = switch(g) {0 => "ok", else => "no"} };
|
||||
\\const a = A{ .x = switch(g) {0 => "ok", else => "no"}, };
|
||||
\\
|
||||
,
|
||||
\\const a = A{ .x = if (f1()) 10 else 20 };
|
||||
\\const a = A{
|
||||
\\ .x = if (f1()) 10 else 20,
|
||||
\\};
|
||||
\\const a = A{ .x = if (f1())
|
||||
\\ 10
|
||||
\\else
|
||||
\\ 20 };
|
||||
\\const a = A{
|
||||
\\ .x = if (f1())
|
||||
\\ 10
|
||||
\\ else
|
||||
\\ 20,
|
||||
\\};
|
||||
\\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 };
|
||||
\\const a = A{
|
||||
\\ .x = if (f1()) 10 else 20,
|
||||
\\ .y = f2() + 100,
|
||||
\\};
|
||||
\\const a = A{ .x = if (f1())
|
||||
\\ 10
|
||||
\\else
|
||||
\\ 20 };
|
||||
\\const a = A{
|
||||
\\ .x = if (f1())
|
||||
\\ 10
|
||||
\\ else
|
||||
\\ 20,
|
||||
\\};
|
||||
\\const a = A{ .x = switch (g) {
|
||||
\\ 0 => "ok",
|
||||
\\ else => "no",
|
||||
\\} };
|
||||
\\const a = A{
|
||||
\\ .x = switch (g) {
|
||||
\\ 0 => "ok",
|
||||
\\ else => "no",
|
||||
\\ },
|
||||
\\};
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
//test "zig fmt: array literal with hint" {
|
||||
// try testTransform(
|
||||
// \\const a = []u8{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user