void () { String in = "@Deprecated\n" + "public class X {}"; final String what = "class '_X {}"; final String replacement = "/** comment */\n" + "class $X$ {}"; final String expected = """ /** comment */ @Deprecated public class X {}"""; assertEquals("keep newline in modifier list", expected, replace(in, what, replacement, true)); }