parser: port array literal hint and vertical alignment tests

Port tests:
- "array literal with hint"
- "array literal vertical column alignment"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-10 18:51:21 +00:00
parent 70cbee78e4
commit 64ce9659de

View File

@@ -2339,6 +2339,130 @@ test "zig fmt: struct literal containing a multiline expression" {
);
}
test "zig fmt: array literal with hint" {
try testTransform(
\\const a = []u8{
\\ 1, 2, //
\\ 3,
\\ 4,
\\ 5,
\\ 6,
\\ 7 };
\\const a = []u8{
\\ 1, 2, //
\\ 3,
\\ 4,
\\ 5,
\\ 6,
\\ 7, 8 };
\\const a = []u8{
\\ 1, 2, //
\\ 3,
\\ 4,
\\ 5,
\\ 6, // blah
\\ 7, 8 };
\\const a = []u8{
\\ 1, 2, //
\\ 3, //
\\ 4,
\\ 5,
\\ 6,
\\ 7 };
\\const a = []u8{
\\ 1,
\\ 2,
\\ 3, 4, //
\\ 5, 6, //
\\ 7, 8, //
\\};
,
\\const a = []u8{
\\ 1, 2, //
\\ 3, 4,
\\ 5, 6,
\\ 7,
\\};
\\const a = []u8{
\\ 1, 2, //
\\ 3, 4,
\\ 5, 6,
\\ 7, 8,
\\};
\\const a = []u8{
\\ 1, 2, //
\\ 3, 4,
\\ 5,
\\ 6, // blah
\\ 7,
\\ 8,
\\};
\\const a = []u8{
\\ 1, 2, //
\\ 3, //
\\ 4,
\\ 5,
\\ 6,
\\ 7,
\\};
\\const a = []u8{
\\ 1,
\\ 2,
\\ 3, 4, //
\\ 5, 6, //
\\ 7, 8, //
\\};
\\
);
}
test "zig fmt: array literal vertical column alignment" {
try testTransform(
\\const a = []u8{
\\ 1000, 200,
\\ 30, 4,
\\ 50000, 60,
\\};
\\const a = []u8{0, 1, 2, 3, 40,
\\ 4,5,600,7,
\\ 80,
\\ 9, 10, 11, 0, 13, 14, 15,};
\\const a = [12]u8{
\\ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
\\const a = [12]u8{
\\ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, };
\\
,
\\const a = []u8{
\\ 1000, 200,
\\ 30, 4,
\\ 50000, 60,
\\};
\\const a = []u8{
\\ 0, 1, 2, 3, 40,
\\ 4, 5, 600, 7, 80,
\\ 9, 10, 11, 0, 13,
\\ 14, 15,
\\};
\\const a = [12]u8{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
\\const a = [12]u8{
\\ 31,
\\ 28,
\\ 31,
\\ 30,
\\ 31,
\\ 30,
\\ 31,
\\ 31,
\\ 30,
\\ 31,
\\ 30,
\\ 31,
\\};
\\
);
}
test "zig fmt: multiline string with backslash at end of line" {
try testCanonical(
\\comptime {