Skip to content

Commit

Permalink
Add Strings.repeat as a regression test for Inliner.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 730917322
  • Loading branch information
graememorgan authored and Error Prone Team committed Feb 28, 2025
1 parent 28f119a commit dd88ef4
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1628,4 +1628,42 @@ private BugCheckerRefactoringTestHelper bugCheckerWithCheckFixCompiles() {
return BugCheckerRefactoringTestHelper.newInstance(Inliner.class, getClass())
.setArgs("-XepOpt:InlineMe:CheckFixCompiles=true");
}

// b/308614050
@Test
public void binaryTree_immediatelyInvoked_requiresParens() {
refactoringTestHelper
.addInputLines(
"Strings.java",
"""
import com.google.errorprone.annotations.InlineMe;
public final class Strings {
@InlineMe(replacement = "string.repeat(count)")
public static String repeat(String string, int count) {
return string.repeat(count);
}
}
""")
.expectUnchanged()
.addInputLines(
"Test.java",
"""
class Test {
void test() {
String s = Strings.repeat("a" + "b", 10);
}
}
""")
.addOutputLines(
"Test.java",
"""
class Test {
void test() {
String s = "a" + "b".repeat(10);
}
}
""")
.doTest();
}
}

0 comments on commit dd88ef4

Please sign in to comment.