From f10be210984947b8f78f5d1b2005d370216b8eea Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 19 Nov 2026 08:47:35 -0800 Subject: [PATCH] Add baseline test case for leading `///` shebang comments. Add `FormatterTest.shebangComment` documenting the existing formatting behavior so that the follow-up change shows the formatting diff. PiperOrigin-RevId: 1025627869 --- .../googlejavaformat/java/FormatterTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/core/src/test/java/com/google/googlejavaformat/java/FormatterTest.java b/core/src/test/java/com/google/googlejavaformat/java/FormatterTest.java index 494c46853..f5a17df27 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/FormatterTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/FormatterTest.java @@ -1368,4 +1368,29 @@ class T { """; assertThat(new Formatter().formatSource(input)).isEqualTo(expected); } + + @Test + public void shebangComment() throws Exception { + String input = + """ + ///usr/bin/env jbang "$0" "$@" ; exit $? + + public class hello { + public static void main(String... args) { + System.out.println("Hello World"); + } + } + """; + String expected = + """ + /// usr/bin/env jbang "$0" "$@" ; exit $? + + public class hello { + public static void main(String... args) { + System.out.println("Hello World"); + } + } + """; + assertThat(new Formatter().formatSource(input)).isEqualTo(expected); + } }