parser: implement switch, port switch comment tests
Implement parseSwitchExpr in parser.c:
- switch(expr) { cases... } with case items, ranges, else
- switch_case_one and switch_case node types
- Proper scratch management for nested case items
Port tests:
- "switch comment before prong"
- "switch comment after prong"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2137,6 +2137,31 @@ test "zig fmt: function call with multiline argument" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: switch comment before prong" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
\\ switch (a) {
|
||||
\\ // hi
|
||||
\\ 0 => {},
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: switch comment after prong" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
\\ switch (a) {
|
||||
\\ 0,
|
||||
\\ // hi
|
||||
\\ => {},
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: if-else with comment before else" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
|
||||
Reference in New Issue
Block a user