zig

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

commit 83da26c1837aad654578dde224c3fde98952db2a (tree)
parent f3a2bb4451bf36b40f8c9036a1156946b4bc7919
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Wed, 11 Feb 2026 07:46:26 +0000

parser: update test bodies to match upstream verbatim

Update test content to match upstream:
- "arrays" (full upstream test content)
- "blocks" (add labeled block and blk: variants)
- "comptime" (full upstream test with comptime var, expressions)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Diffstat:
Mparser_test.zig | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 54 insertions(+), 10 deletions(-)

diff --git a/parser_test.zig b/parser_test.zig @@ -3198,11 +3198,17 @@ test "zig fmt: union declaration" { test "zig fmt: arrays" { try testCanonical( - \\test "arrays" { - \\ const a: [2]u32 = .{ 1, 2 }; - \\ const b = a ++ a; - \\ const c = a[0..]; - \\ _ = c; + \\test "test array" { + \\ const a: [2]u8 = [2]u8{ + \\ 1, + \\ 2, + \\ }; + \\ const a: [2]u8 = []u8{ + \\ 1, + \\ 2, + \\ }; + \\ const a: [0]u8 = []u8{}; + \\ const x: [4:0]u8 = undefined; \\} \\ ); @@ -3245,11 +3251,21 @@ test "zig fmt: catch" { test "zig fmt: blocks" { try testCanonical( - \\test { + \\test "blocks" { \\ { - \\ const a = b; + \\ const a = 0; + \\ const b = 0; \\ } - \\ const c = d; + \\ + \\ blk: { + \\ const a = 0; + \\ const b = 0; + \\ } + \\ + \\ const r = blk: { + \\ const a = 0; + \\ const b = 0; + \\ }; \\} \\ ); @@ -3794,9 +3810,37 @@ test "zig fmt: defer" { test "zig fmt: comptime" { try testCanonical( - \\fn foo() void { + \\fn a() u8 { + \\ return 5; + \\} + \\ + \\fn b(comptime i: u8) u8 { + \\ return i; + \\} + \\ + \\const av = comptime a(); + \\const av2 = comptime blk: { + \\ var res = a(); + \\ res *= b(2); + \\ break :blk res; + \\}; + \\ + \\comptime { + \\ _ = a(); + \\} + \\ + \\test "comptime" { + \\ const av3 = comptime a(); + \\ const av4 = comptime blk: { + \\ var res = a(); + \\ res *= a(); + \\ break :blk res; + \\ }; + \\ + \\ comptime var i = 0; \\ comptime { - \\ bar(); + \\ i = a(); + \\ i += b(i); \\ } \\} \\