parser: update test bodies to match upstream verbatim

Update test content to match upstream exactly:
- "comptime block in container"
- "comment after empty comment"
- "comment after params"
- "decimal float literals with underscore separators"
- "container doc comments"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-11 09:18:28 +00:00
parent 7a414e8731
commit 801dfc6c6e

View File

@@ -3922,11 +3922,15 @@ test "zig fmt: error return" {
test "zig fmt: comptime block in container" { test "zig fmt: comptime block in container" {
try testCanonical( try testCanonical(
\\const Foo = struct { \\pub fn container() type {
\\ comptime { \\ return struct {
\\ @compileLog("hello comptime"); \\ comptime {
\\ } \\ if (false) {
\\}; \\ unreachable;
\\ }
\\ }
\\ };
\\}
\\ \\
); );
} }
@@ -4002,9 +4006,10 @@ test "zig fmt: file ends with struct field" {
test "zig fmt: comment after empty comment" { test "zig fmt: comment after empty comment" {
try testCanonical( try testCanonical(
\\const x = true; //
\\// \\//
\\/// A doc comment \\//
\\const a = b; \\//a
\\ \\
); );
} }
@@ -4042,10 +4047,26 @@ test "zig fmt: line comment in array" {
} }
test "zig fmt: comment after params" { test "zig fmt: comment after params" {
try testTransform(
\\fn a(
\\ b: u32
\\ // c: u32,
\\ // d: u32,
\\) void {}
\\
,
\\fn a(
\\ b: u32,
\\ // c: u32,
\\ // d: u32,
\\) void {}
\\
);
try testCanonical( try testCanonical(
\\fn foo( \\fn a(
\\ a: i32, // comment \\ b: u32,
\\ b: i32, // comment \\ // c: u32,
\\ // d: u32,
\\) void {} \\) void {}
\\ \\
); );
@@ -4119,7 +4140,53 @@ test "zig fmt: container doc comments" {
\\//! tld 1 \\//! tld 1
\\//! tld 2 \\//! tld 2
\\//! tld 3 \\//! tld 3
\\const a = b; \\
\\// comment
\\
\\/// A doc
\\const A = struct {
\\ //! A tld 1
\\ //! A tld 2
\\ //! A tld 3
\\};
\\
\\/// B doc
\\const B = struct {
\\ //! B tld 1
\\ //! B tld 2
\\ //! B tld 3
\\
\\ /// B doc
\\ b: u32,
\\};
\\
\\/// C doc
\\const C = union(enum) { // comment
\\ //! C tld 1
\\ //! C tld 2
\\ //! C tld 3
\\};
\\
\\/// D doc
\\const D = union(Foo) {
\\ //! D tld 1
\\ //! D tld 2
\\ //! D tld 3
\\
\\ /// D doc
\\ b: u32,
\\};
\\
);
try testCanonical(
\\//! Top-level documentation.
\\
\\/// This is A
\\pub const A = usize;
\\
);
try testCanonical(
\\//! Nothing here
\\ \\
); );
} }
@@ -4296,10 +4363,18 @@ test "zig fmt: hex literals with underscore separators" {
} }
test "zig fmt: decimal float literals with underscore separators" { test "zig fmt: decimal float literals with underscore separators" {
try testCanonical( try testTransform(
\\const x = 1_234_567.89_10_11; \\pub fn main() void {
\\const y = 1_234_567.89_10_11e1_213_14; \\ const a:f64=(10.0e-0+(10.0e+0))+10_00.00_00e-2+20_00.00_10e+4;
\\const z = 1_234_567; \\ const b:f64=1_0.0--10_10.0+1_0_0.0_0+1e2;
\\ std.debug.warn("a: {}, b: {} -> a+b: {}\n", .{ a, b, a + b });
\\}
,
\\pub fn main() void {
\\ const a: f64 = (10.0e-0 + (10.0e+0)) + 10_00.00_00e-2 + 20_00.00_10e+4;
\\ const b: f64 = 1_0.0 - -10_10.0 + 1_0_0.0_0 + 1e2;
\\ std.debug.warn("a: {}, b: {} -> a+b: {}\n", .{ a, b, a + b });
\\}
\\ \\
); );
} }