From 6bd0bdd7ed151650c43082b929add74c4b57e584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 11 Feb 2026 06:46:01 +0000 Subject: [PATCH] parser: update test bodies to match upstream verbatim Update test content to match upstream exactly: - "block with same line comment after end brace" - "comments before var decl in struct" - "comments before global variables" - "comments in statements" - "comments before test decl" Co-Authored-By: Claude Opus 4.6 (1M context) --- parser_test.zig | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/parser_test.zig b/parser_test.zig index 9f945ad016..ab26f4603c 100644 --- a/parser_test.zig +++ b/parser_test.zig @@ -2336,10 +2336,10 @@ test "zig fmt: nested blocks" { test "zig fmt: block with same line comment after end brace" { try testCanonical( - \\test { + \\comptime { \\ { - \\ const a = b; - \\ } // end of block + \\ b(); + \\ } // comment \\} \\ ); @@ -2667,9 +2667,24 @@ test "zig fmt: comments before switch prong" { test "zig fmt: comments before var decl in struct" { try testCanonical( - \\const Foo = struct { - \\ /// comment - \\ bar: bool = true, + \\pub const vfs_cap_data = extern struct { + \\ // All of these are mandated as little endian + \\ // when on disk. + \\ const Data = struct { + \\ permitted: u32, + \\ inheritable: u32, + \\ }; + \\ + \\ // in between + \\ + \\ /// All of these are mandated as little endian + \\ /// when on disk. + \\ const Data = struct { + \\ permitted: u32, + \\ inheritable: u32, + \\ }; + \\ + \\ // at end \\}; \\ ); @@ -2684,20 +2699,23 @@ test "zig fmt: array literal with 1 item on 1 line" { test "zig fmt: comments before global variables" { try testCanonical( - \\/// comment - \\var foo: i32 = undefined; + \\/// Foo copies keys and values before they go into the map, and + \\/// frees them when they get removed. + \\pub const Foo = struct {}; \\ ); } test "zig fmt: comments in statements" { try testCanonical( - \\comptime { - \\ // a + \\test "std" { + \\ // statement comment + \\ _ = @import("foo/bar.zig"); \\ - \\ const x = 42; // b + \\ // middle + \\ // middle2 \\ - \\ // c + \\ // end \\} \\ ); @@ -2705,9 +2723,13 @@ test "zig fmt: comments in statements" { test "zig fmt: comments before test decl" { try testCanonical( - \\/// top level doc comment + \\// top level normal comment \\test "hi" {} \\ + \\// middle + \\ + \\// end + \\ ); }