parser: port test "switch multiline string"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-10 22:50:13 +00:00
parent 9eebba10ea
commit 571fb20bb7

View File

@@ -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"{