From 83da26c1837aad654578dde224c3fde98952db2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 11 Feb 2026 07:46:26 +0000 Subject: [PATCH] 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) --- parser_test.zig | 64 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/parser_test.zig b/parser_test.zig index 64a52a5365..d40aabeafe 100644 --- 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); \\ } \\} \\