diff --git a/parser_test.zig b/parser_test.zig index 385d2153e1..11a8f119e4 100644 --- a/parser_test.zig +++ b/parser_test.zig @@ -543,6 +543,7 @@ fn testCanonical(source: [:0]const u8) !void { } + test "zig fmt: remove extra whitespace at start and end of file with comment between" { try testTransform( \\ @@ -2723,37 +2724,6 @@ test "zig fmt: nested struct literal with one item" { ); } -test "zig fmt: switch multiline string" { - try testCanonical( - \\test "switch multiline string" { - \\ const x: u32 = 0; - \\ const str = switch (x) { - \\ 1 => "one", - \\ 2 => - \\ \\ Comma after the multiline string - \\ \\ is needed - \\ , - \\ 3 => "three", - \\ else => "else", - \\ }; - \\ - \\ const Union = union(enum) { - \\ Int: i64, - \\ Float: f64, - \\ }; - \\ - \\ const str = switch (u) { - \\ Union.Int => |int| - \\ \\ Comma after the multiline string - \\ \\ is needed - \\ , - \\ Union.Float => |*float| unreachable, - \\ }; - \\} - \\ - ); -} - test "zig fmt: switch cases trailing comma" { try testTransform( \\test "switch cases trailing comma"{ @@ -3778,6 +3748,37 @@ test "zig fmt: switch" { ); } +test "zig fmt: switch multiline string" { + try testCanonical( + \\test "switch multiline string" { + \\ const x: u32 = 0; + \\ const str = switch (x) { + \\ 1 => "one", + \\ 2 => + \\ \\ Comma after the multiline string + \\ \\ is needed + \\ , + \\ 3 => "three", + \\ else => "else", + \\ }; + \\ + \\ const Union = union(enum) { + \\ Int: i64, + \\ Float: f64, + \\ }; + \\ + \\ const str = switch (u) { + \\ Union.Int => |int| + \\ \\ Comma after the multiline string + \\ \\ is needed + \\ , + \\ Union.Float => |*float| unreachable, + \\ }; + \\} + \\ + ); +} + test "zig fmt: while" { try testCanonical( \\test "while" { @@ -4249,3 +4250,4 @@ test "my function" { \\ ); } +