Skip to content

Commit

Permalink
Add a failing test in CheckReturnValueTest
Browse files Browse the repository at this point in the history
  • Loading branch information
hisener committed Oct 14, 2021
1 parent d2764b9 commit 769049b
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.errorprone.bugpatterns;

import com.google.errorprone.BugCheckerRefactoringTestHelper;
import com.google.errorprone.CompilationTestHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -645,4 +646,32 @@ public void noCRVonClasspath() {
.withClasspath(CRVTest.class, CheckReturnValueTest.class)
.doTest();
}

@Test
public void effectivelyFinal() {
String[] input = {
"import com.google.errorprone.annotations.CheckReturnValue;",
"import java.util.List;",
"",
"public class TestClass {",
" public void test() {",
" var variable = new CustomType();",
" // BUG: Diagnostic contains: Ignored return value",
" List.of(1).forEach(unused -> variable.get());",
" }",
" static final class CustomType {",
" @CheckReturnValue",
" public CustomType get() {",
" return null;",
" }",
" }",
"}"
};
compilationHelper.addSourceLines("TestClass.java", input).doTest();

BugCheckerRefactoringTestHelper.newInstance(CheckReturnValue.class, getClass())
.addInputLines("TestClass.java", input)
.expectUnchanged()
.doTest();
}
}

0 comments on commit 769049b

Please sign in to comment.