zig fmt: Respect line breaks in struct default value decls
Bring this in line with how variable declarations are handled. Open a new indentation level for the initialization expression to handle nested expressions like blocks. Closes #7618
This commit is contained in:
@@ -4,6 +4,31 @@
|
||||
// The MIT license requires this copyright notice to be included in all copies
|
||||
// and substantial portions of the software.
|
||||
|
||||
test "zig fmt: respect line breaks in struct field value declaration" {
|
||||
try testCanonical(
|
||||
\\const Foo = struct {
|
||||
\\ bar: u32 =
|
||||
\\ 42,
|
||||
\\ bar: u32 =
|
||||
\\ // a comment
|
||||
\\ 42,
|
||||
\\ bar: u32 =
|
||||
\\ 42,
|
||||
\\ // a comment
|
||||
\\ bar: []const u8 =
|
||||
\\ \\ foo
|
||||
\\ \\ bar
|
||||
\\ \\ baz
|
||||
\\ ,
|
||||
\\ bar: u32 =
|
||||
\\ blk: {
|
||||
\\ break :blk 42;
|
||||
\\ },
|
||||
\\};
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
// TODO Remove this after zig 0.9.0 is released.
|
||||
test "zig fmt: rewrite inline functions as callconv(.Inline)" {
|
||||
try testTransform(
|
||||
|
||||
Reference in New Issue
Block a user