From 715298ed233d2db48df15df5beec803dfc93043c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Balv=C3=ADn?= Date: Wed, 7 Oct 2026 12:59:54 +0200 Subject: [PATCH] test(format): keep the expansion signature off the EOF comment newline An unterminated block comment at the end of a file swallows the formatter's mandatory final newline, an artifact the token view already documents as layout; the preproc signature entry now trims it so the invariant stays about tokens. The triggering input joins the corpus. Assisted-by: GLM 5.3 --- format/format_test.go | 6 +++++- .../fuzz/FuzzFormatExpansionRoundTrip/062b12d69fb9426b | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 format/testdata/fuzz/FuzzFormatExpansionRoundTrip/062b12d69fb9426b diff --git a/format/format_test.go b/format/format_test.go index a94f56c..5f03cc5 100644 --- a/format/format_test.go +++ b/format/format_test.go @@ -491,7 +491,11 @@ func stmtSignature(f *ast.File) []string { case *ast.Include: out = append(out, "include "+d.Header.Text) case *ast.Preproc: - out = append(out, "preproc "+d.Raw) + // An unterminated block comment at the end of the file swallows + // the formatter's mandatory final newline, exactly the artifact + // the token view documents as layout; trimming it keeps the + // signature about tokens, not about that newline. + out = append(out, "preproc "+strings.TrimRight(d.Raw, " \t\r\n")) } } for _, s := range f.Orphans { diff --git a/format/testdata/fuzz/FuzzFormatExpansionRoundTrip/062b12d69fb9426b b/format/testdata/fuzz/FuzzFormatExpansionRoundTrip/062b12d69fb9426b new file mode 100644 index 0000000..7fb5b1f --- /dev/null +++ b/format/testdata/fuzz/FuzzFormatExpansionRoundTrip/062b12d69fb9426b @@ -0,0 +1,2 @@ +go test fuzz v1 +string("#/*0")