From 508a94dd33b4fd1fd7c075ecf4aec6f37e7b8869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 10 Feb 2026 17:24:56 +0000 Subject: [PATCH] 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) --- parser_test.zig | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/parser_test.zig b/parser_test.zig index 107337e408..6116330388 100644 --- a/parser_test.zig +++ b/parser_test.zig @@ -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 {