Skip to content

Commit

Permalink
Add a test for the broken behavior due to missing grouping parenthesis.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 684584755
  • Loading branch information
kluever authored and Error Prone Team committed Oct 10, 2024
1 parent 5145dae commit 1dbcb6e
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,46 @@ public void doTest() {
.doTest();
}

@Test
public void math_b308614050() {
refactoringTestHelper
.addInputLines(
"Client.java",
"""
package com.google.foo;
import com.google.errorprone.annotations.InlineMe;
public final class Client {
@InlineMe(replacement = "x * 2")
public static int timesTwo(int x) {
return x * 2;
}
}
""")
.expectUnchanged()
.addInputLines(
"Caller.java",
"""
import com.google.foo.Client;
public final class Caller {
public void doTest() {
long four = Client.timesTwo(1 + 1);
}
}
""")
// This is a bug since it now evaluates to 3, not 4!
.addOutputLines(
"Caller.java",
"""
import com.google.foo.Client;
public final class Caller {
public void doTest() {
long four = 1 + 1 * 2;
}
}
""")
.doTest();
}

private BugCheckerRefactoringTestHelper bugCheckerWithPrefixFlag(String prefix) {
return BugCheckerRefactoringTestHelper.newInstance(Inliner.class, getClass())
.setArgs("-XepOpt:" + PREFIX_FLAG + "=" + prefix);
Expand Down

0 comments on commit 1dbcb6e

Please sign in to comment.