parser: port array/slice literal and pointer type tests

- "sentinel array literal 1 element"
- "anon literal in array"
- "Unicode code point literal larger than u8"
- "slices with spaces in bounds"
- "C pointers"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-10 17:24:56 +00:00
parent 19c36c5dcb
commit 508a94dd33

View File

@@ -1817,6 +1817,53 @@ test "zig fmt: c pointer type" {
);
}
test "zig fmt: sentinel array literal 1 element" {
try testCanonical(
\\test {
\\ const x = [_:9000]u32{a};
\\}
\\
);
}
test "zig fmt: anon literal in array" {
try testCanonical(
\\var arr: [2]Foo = .{
\\ .{ .a = 2 },
\\ .{ .b = 3 },
\\};
\\
);
}
test "zig fmt: Unicode code point literal larger than u8" {
try testCanonical(
\\test {
\\ const x = X{
\\ .a = b,
\\ };
\\}
\\
);
}
test "zig fmt: slices with spaces in bounds" {
try testCanonical(
\\const a = b[0 + 0 ..];
\\const c = d[0 + 0 .. 1];
\\const c = d[0 + 0 .. :0];
\\const e = f[0 .. 1 + 1 :0];
\\
);
}
test "zig fmt: C pointers" {
try testCanonical(
\\const Ptr = [*c]i32;
\\
);
}
test "zig fmt: sentinel-terminated array type" {
try testCanonical(
\\pub fn cStrToPrefixedFileW(s: [*:0]const u8) ![PATH_MAX_WIDE:0]u16 {