zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 508a94dd33b4fd1fd7c075ecf4aec6f37e7b8869 (tree)
parent 19c36c5dcb2191670886a38498a99b051b563440
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Tue, 10 Feb 2026 17:24:56 +0000

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>

Diffstat:
Mparser_test.zig | 47+++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+), 0 deletions(-)

diff --git 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 {