diff --git a/parser_test.zig b/parser_test.zig index 1da5422e35..c1707dd43d 100644 --- a/parser_test.zig +++ b/parser_test.zig @@ -2723,6 +2723,37 @@ 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"{