Skip to content

Commit 41ee638

Browse files
cushonError Prone Team
authored andcommitted
Demonstrate that FloggerSplitLogStatement handles var
PiperOrigin-RevId: 390460015
1 parent b894205 commit 41ee638

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

core/src/test/java/com/google/errorprone/bugpatterns/flogger/FloggerSplitLogStatementTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package com.google.errorprone.bugpatterns.flogger;
1818

19+
import static org.junit.Assume.assumeTrue;
20+
1921
import com.google.errorprone.CompilationTestHelper;
22+
import com.google.errorprone.util.RuntimeVersion;
2023
import org.junit.Test;
2124
import org.junit.runner.RunWith;
2225
import org.junit.runners.JUnit4;
@@ -48,6 +51,24 @@ public void positive() {
4851
.doTest();
4952
}
5053

54+
@Test
55+
public void positiveVar() {
56+
assumeTrue(RuntimeVersion.isAtLeast10());
57+
compilationHelper
58+
.addSourceLines(
59+
"Test.java",
60+
"import com.google.common.flogger.FluentLogger;",
61+
"class Test {",
62+
" private static final FluentLogger logger = FluentLogger.forEnclosingClass();",
63+
" void splitLog() {",
64+
" // BUG: Diagnostic contains:",
65+
" var api = logger.atInfo();",
66+
" api.log(\"foo\");",
67+
" }",
68+
"}")
69+
.doTest();
70+
}
71+
5172
@Test
5273
public void negative() {
5374
compilationHelper

0 commit comments

Comments
 (0)