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) <noreply@anthropic.com>
This commit is contained in:
2026-02-11 06:46:01 +00:00
parent 885581323c
commit 6bd0bdd7ed

View File

@@ -2336,10 +2336,10 @@ test "zig fmt: nested blocks" {
test "zig fmt: block with same line comment after end brace" { test "zig fmt: block with same line comment after end brace" {
try testCanonical( try testCanonical(
\\test { \\comptime {
\\ { \\ {
\\ const a = b; \\ b();
\\ } // end of block \\ } // comment
\\} \\}
\\ \\
); );
@@ -2667,9 +2667,24 @@ test "zig fmt: comments before switch prong" {
test "zig fmt: comments before var decl in struct" { test "zig fmt: comments before var decl in struct" {
try testCanonical( try testCanonical(
\\const Foo = struct { \\pub const vfs_cap_data = extern struct {
\\ /// comment \\ // All of these are mandated as little endian
\\ bar: bool = true, \\ // 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" { test "zig fmt: comments before global variables" {
try testCanonical( try testCanonical(
\\/// comment \\/// Foo copies keys and values before they go into the map, and
\\var foo: i32 = undefined; \\/// frees them when they get removed.
\\pub const Foo = struct {};
\\ \\
); );
} }
test "zig fmt: comments in statements" { test "zig fmt: comments in statements" {
try testCanonical( try testCanonical(
\\comptime { \\test "std" {
\\ // a \\ // 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" { test "zig fmt: comments before test decl" {
try testCanonical( try testCanonical(
\\/// top level doc comment \\// top level normal comment
\\test "hi" {} \\test "hi" {}
\\ \\
\\// middle
\\
\\// end
\\
); );
} }